Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ“ chore: GA ์ดˆ๊ธฐํ™”ํ•˜๋Š” ์œ„์น˜๋ฅผ App.tsx๋กœ ์ด๋™, ์ดˆ๊ธฐ์— ๋ธŒ๋ผ์šฐ์ € ์ •๋ณด ๋‚จ๊ธฐ๊ธฐ #440

Open
wants to merge 1 commit into
base: v1.0.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { useEffect } from 'react';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์šฐ๋ฆฌ์˜ ์ปจ๋ฒค์…˜์„ ...... ์ฝ”๋“œ ํฌ๋งทํ„ฐ๊ฐ€ ๋‹ค ๋ถ€์ˆ˜๊ณ  ์žˆ์–ด์—ฌ ใ…œใ…œใ…œใ…œใ…œใ…œใ…œใ…œใ…œ
์ด๊ฑฐ๋Š” ์—ฌํ–‰ ๋‹ค๋…€์˜ค์ž๋งˆ์ž ํ•œ๋ฒˆ์— ๊ณ ์น˜๋Š” ๋ฐฉ๋ฒ•์„ ์ฐพ์•„๋ณผ๊ฒŒ์š”!! (๋ฌผ๋ก  ๋Œ€์‹  ์ฐพ์•„์ฃผ์…”๋„ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹น)

import { BrowserRouter } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from 'react-query';
import { BrowserRouter } from 'react-router-dom';

import GlobalStyle from '@styles/global';
import Router from '@routes/Router';
import { useLoginUser } from '@hooks/useLoginUser';
import ToastList from '@components/common/Toast/List';
import { GaAction, GaCategory, useGoogleAnalytics } from '@hooks/useGoogleAnalytics';
import { useLoginUser } from '@hooks/useLoginUser';
import Router from '@routes/Router';
import GlobalStyle from '@styles/global';
import ReactGA from 'react-ga';

function App() {
const { initLoginUser } = useLoginUser();
const { initLoginUser, userID, isAuthenticated } = useLoginUser();
const { isGoogleAnalyticsLoaded, makeGaEvent } = useGoogleAnalytics();

const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -22,6 +25,19 @@ function App() {
initLoginUser();
}, []);

useEffect(() => {
if (isGoogleAnalyticsLoaded) {
makeGaEvent({
category: GaCategory.INIT,
action: GaAction.USER_AGENT,
label: navigator.userAgent,
});
if (isAuthenticated) {
ReactGA.set({ userID });
}
}
}, [isGoogleAnalyticsLoaded, isAuthenticated]);

return (
<>
<GlobalStyle />
Expand Down
2 changes: 2 additions & 0 deletions src/application/hooks/useGoogleAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { useEffect, useState } from 'react';
import ReactGA from 'react-ga';

export const enum GaCategory {
INIT = 'init',
LANDING = 'landing',
TSS = 'tss',
NSS = 'nss',
}

export const enum GaAction {
USER_AGENT = 'user_agent',
CLICK = 'click',
}

Expand Down
36 changes: 23 additions & 13 deletions src/presentation/pages/Landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import {
imgGlass,
imgLanding,
imgLink,
imgMainPage,
imgMypage,
imgTeamsoseo,
} from '@assets/images';
import TeamLandingLottie from '@assets/lottie/TeamLottie';
import CommonHeader from '@components/common/Header';
import { GaAction, GaCategory, useGoogleAnalytics } from '@hooks/useGoogleAnalytics';
import { useLoginUser } from '@hooks/useLoginUser';
import { useNavigate } from 'react-router-dom';
import { useEffect } from 'react';
import CommonHeader from '@components/common/Header';
import { useNavigate } from 'react-router-dom';
import {
StFooter,
StLandingWrapper,
Expand All @@ -16,16 +26,6 @@ import {
StServiceButton,
StShadow,
} from './style';
import {
imgGlass,
imgLanding,
imgLink,
imgMainPage,
imgMypage,
imgTeamsoseo,
} from '@assets/images';
import TeamLandingLottie from '@assets/lottie/TeamLottie';
import { GaAction, GaCategory, useGoogleAnalytics } from '@hooks/useGoogleAnalytics';

function Landing() {
const { isAuthenticated } = useLoginUser();
Expand All @@ -49,7 +49,17 @@ function Landing() {
</div>
<img src={imgMainPage} />
<StShadow top={161} />
<StServiceButton theme="coral" onClick={() => navigate(`/login`)}>
<StServiceButton
theme="coral"
onClick={() => {
makeGaEvent({
category: GaCategory.LANDING,
action: GaAction.CLICK,
label: 'login_top',
});
navigate(`/login`);
}}
>
๋„ˆ๊ฐ€์†Œ๊ฐœ์„œ ๋ฐ›์œผ๋Ÿฌ ๊ฐ€๊ธฐ
</StServiceButton>
</StMain>
Expand Down
18 changes: 8 additions & 10 deletions src/presentation/routes/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import ScrollToTop from '@components/common/ScrollToTop';
import InAppBrowserEscape from '@components/InAppBrowserEscape';
import { useGoogleAnalytics } from '@hooks/useGoogleAnalytics';
import { Suspense, useEffect } from 'react';
import ReactGA from 'react-ga';
import { Route, Routes, useLocation } from 'react-router-dom';
import FormRouter from './FormRouter';
import NeogaRouter from './NeogaRouter';
import PreferencesRouter from './PreferencesRouter';
import TeamRouter from './TeamRouter';
import UserRouter from './UserRouter';
import ReactGA from 'react-ga';
import FormRouter from './FormRouter';
import { useLoginUser } from '@hooks/useLoginUser';
import PreferencesRouter from './PreferencesRouter';
import InAppBrowserEscape from '@components/InAppBrowserEscape';

const Router = () => {
const location = useLocation();
const { isGoogleAnalyticsLoaded } = useGoogleAnalytics();
const { isAuthenticated, userID } = useLoginUser();

useEffect(() => {
if (isGoogleAnalyticsLoaded) ReactGA.pageview(location.pathname + location.search);
if (isGoogleAnalyticsLoaded && isAuthenticated) {
ReactGA.set({ userID });
if (isGoogleAnalyticsLoaded) {
ReactGA.pageview(location.pathname + location.search);
}
}, [isGoogleAnalyticsLoaded, location, isAuthenticated]);
}, [isGoogleAnalyticsLoaded, location]);

return (
<>
<ScrollToTop />
Expand Down