Skip to content

Commit 18f5eb7

Browse files
committed
fix: GA pageview element 제거 작업
1 parent 2b59eb3 commit 18f5eb7

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

src/App.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,36 @@ const PageTracker = () => {
2626
const { pathname, state } = location;
2727

2828
const trackedPaths = [
29-
{ path: "/", page: "홈", element: "" },
30-
{ path: "/login", page: "로그인/회원가입", element: "로그인" },
31-
{ path: "/contents", page: "일반콘텐츠", element: "" },
32-
{ path: "/my-info", page: "내 정보", element: "" },
33-
{ path: "/chat", page: "채팅방", element: "" },
34-
{ path: "/select-info", page: "빠른 대화 설정", element: "" },
35-
{ path: "/select-info", page: "친구 저장", element: "대화 시작하기" }
29+
{ path: "/", page: "홈" },
30+
{ path: "/login", page: "로그인/회원가입" },
31+
{ path: "/contents", page: "일반콘텐츠" },
32+
{ path: "/my-info", page: "내 정보" },
33+
{ path: "/chat", page: "채팅방" },
34+
{ path: "/select-info", page: "빠른 대화 설정" },
35+
{ path: "/select-info", page: "친구 저장" }
3636
];
3737

3838
useEffect(() => {
3939
const trackedContentPaths = ["/contents/1", "/contents/2"];
4040

41-
trackedPaths.forEach(({ path, page, element }) => {
41+
trackedPaths.forEach(({ path, page }) => {
4242
// 콘텐츠 상세 페이지 (일반 콘텐츠만 추적)
4343
if (trackedContentPaths.includes(pathname)) {
4444
if (path === "/contents") {
45-
trackPageView(path, { page, element });
45+
trackPageView(path, page);
4646
}
4747
}
4848
// select-info 페이지에서 state로 분기
4949
else if (pathname === "/select-info" && path === pathname) {
5050
if (state === "fastFriend" && page === "빠른 대화 설정") {
51-
trackPageView(path, { page, element });
51+
trackPageView(path, page);
5252
} else if (state === "virtualFriend" && page === "친구 저장") {
53-
trackPageView(path, { page, element });
53+
trackPageView(path, page);
5454
}
5555
}
5656
// 나머지 일반 path
5757
else if (pathname === path && path !== "/select-info") {
58-
trackPageView(path, { page, element });
58+
trackPageView(path, page);
5959
}
6060
});
6161
}, [location.pathname, location.state]);
@@ -84,7 +84,7 @@ const App = () => {
8484
<Route path="/login" element={<Login />} />
8585
<Route path="/my-info" element={<MyInfo />} />
8686
<Route path="/kakao-login" element={<KaKaoLogin />} />
87-
<Route path="/mbti-test" element={<MbtiTestIntro />} />
87+
<Route path="/mbti-test" element={<MbtiTestIntro />} />
8888
<Route path="/mbti-test-progress" element={<MbtiTestQuestions />} />
8989
<Route path="/mbti-test-result" element={<MbtiTestResult />} />
9090
</Routes>

src/libs/analytics.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,22 @@ const GA_MEASUREMENT_ID = import.meta.env.VITE_GA_MEASUREMENT_ID || "";
55
const isProduction = import.meta.env.MODE === "production";
66

77
export const initGA = () => {
8-
console.log("isProduction", isProduction);
9-
console.log("ID", GA_MEASUREMENT_ID);
108
if (isProduction && GA_MEASUREMENT_ID) {
11-
console.log("initGA");
129
ReactGA.initialize(GA_MEASUREMENT_ID);
1310
}
1411
};
1512

16-
export const trackPageView = (url: string, params?: Record<string, string>) => {
13+
export const trackPageView = (url: string, page: string) => {
1714
if (isProduction && GA_MEASUREMENT_ID) {
18-
console.log("trackPageView");
1915
ReactGA.gtag("event", "page_view", {
2016
page_path: url,
21-
...params
17+
page: page
2218
});
2319
}
2420
};
2521

2622
export const trackEvent = (name: string, params?: Record<string, string>) => {
2723
if (isProduction && GA_MEASUREMENT_ID) {
28-
console.log("trackEvent");
2924
ReactGA.event(name, params);
3025
}
3126
};

0 commit comments

Comments
 (0)