Skip to content

Commit b972b7d

Browse files
youngminssclaude
andcommitted
refactor: 코드 리뷰 피드백 반영
- useEffect 의존성 배열 개선 (optional chaining 제거) - trackPageView를 trackViewPage로 리네이밍 및 이벤트명 내부 고정 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2390f47 commit b972b7d

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed

app/gathering/[accessKey]/opinion/complete/CompleteViewContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect } from "react";
44
import { useParams, redirect } from "next/navigation";
55

6-
import { trackCtaClick, trackPageView } from "#/components/analytics";
6+
import { trackCtaClick, trackViewPage } from "#/components/analytics";
77
import { Button } from "#/components/button";
88
import { Layout } from "#/components/layout";
99
import {
@@ -31,15 +31,15 @@ export function CompleteViewContainer() {
3131
};
3232

3333
useEffect(() => {
34-
if (!isPending && capacity?.currentCount && capacity?.maxCount) {
35-
trackPageView("view_page", {
34+
if (!isPending && capacity) {
35+
trackViewPage({
3636
page_id: PAGE_ID,
3737
submit_progress: Math.round(
3838
(capacity.currentCount / capacity.maxCount) * 100,
3939
),
4040
});
4141
}
42-
}, [isPending, capacity?.currentCount, capacity?.maxCount]);
42+
}, [capacity, isPending]);
4343

4444
return (
4545
<Layout.Root>

app/gathering/[accessKey]/opinion/pending/PendingViewContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect } from "react";
44
import { useParams, redirect } from "next/navigation";
55

6-
import { trackPageView, trackShareClick } from "#/components/analytics";
6+
import { trackViewPage, trackShareClick } from "#/components/analytics";
77
import { Button } from "#/components/button";
88
import { Layout } from "#/components/layout";
99
import {
@@ -38,17 +38,17 @@ export function PendingViewContainer() {
3838
};
3939

4040
useEffect(() => {
41-
if (!isComplete && capacity?.currentCount && capacity?.maxCount) {
41+
if (!isComplete && capacity) {
4242
const progress = Math.round(
4343
(capacity.currentCount / capacity.maxCount) * 100,
4444
);
4545

46-
trackPageView("view_page", {
46+
trackViewPage({
4747
page_id: PAGE_ID,
4848
submit_progress: progress,
4949
});
5050
}
51-
}, [isComplete, capacity?.currentCount, capacity?.maxCount]);
51+
}, [capacity, isComplete]);
5252

5353
return (
5454
<Layout.Root>

app/gathering/[accessKey]/opinion/result/ResultViewContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect } from "react";
44
import { useParams, redirect } from "next/navigation";
55

6-
import { trackPageView, trackShareClick } from "#/components/analytics";
6+
import { trackViewPage, trackShareClick } from "#/components/analytics";
77
import { Layout } from "#/components/layout";
88
import { ShareButton } from "#/components/shareButton";
99
import { ResultView } from "#/pageComponents/gathering/opinion";
@@ -35,7 +35,7 @@ export function ResultViewContainer() {
3535

3636
useEffect(() => {
3737
if (isComplete && recommendationResult && accessKey) {
38-
trackPageView("view_page", {
38+
trackViewPage({
3939
page_id: PAGE_ID,
4040
group_id: accessKey,
4141
});

app/gathering/create/complete/[accessKey]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useEffect } from "react";
55

66
import { twJoin } from "tailwind-merge";
77

8-
import { trackCtaClick, trackPageView } from "#/components/analytics";
8+
import { trackCtaClick, trackViewPage } from "#/components/analytics";
99
import { Layout } from "#/components/layout";
1010
import { Button } from "#/components/button";
1111
import { MeetingCompleteIllustration } from "#/components/illustrations";
@@ -30,7 +30,7 @@ export default function GatheringCreateCompletePage() {
3030
useEffect(() => {
3131
if (!params.accessKey) return;
3232

33-
trackPageView("view_page", {
33+
trackViewPage({
3434
page_id: PAGE_ID,
3535
group_id: params.accessKey,
3636
});

src/components/analytics/events.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ export const trackEvent = (
4040
* 페이지 진입 이벤트
4141
*
4242
* @example
43-
* trackPageView("view_onboarding", { page_id: "onboarding" });
44-
* trackPageView("view_complete", { page_id: "create_complete", group_id: "abc123" });
43+
* trackViewPage({ page_id: "onboarding" });
44+
* trackViewPage({ page_id: "create_complete", group_id: "abc123" });
4545
*/
46-
export const trackPageView = (
47-
eventName: string,
46+
export const trackViewPage = (
4847
params: { page_id: string } & Record<string, string | number | boolean>,
4948
) => {
50-
trackEvent(eventName, params);
49+
trackEvent("view_page", params);
5150
};
5251

5352
/**

src/components/analytics/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { Analytics } from "./Analytics";
22
export {
33
trackEvent,
4-
trackPageView,
4+
trackViewPage,
55
trackCtaClick,
66
trackStepComplete,
77
trackShareClick,

src/pageComponents/gathering/opinion/LandingView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { redirect, useParams, useRouter } from "next/navigation";
44
import { useEffect } from "react";
55

6-
import { trackCtaClick, trackPageView } from "#/components/analytics";
6+
import { trackCtaClick, trackViewPage } from "#/components/analytics";
77
import { IntroStep } from "#/pageComponents/gathering/opinion";
88
import { Button } from "#/components/button";
99
import { Layout } from "#/components/layout";
@@ -33,13 +33,13 @@ export function LandingView() {
3333
};
3434

3535
useEffect(() => {
36-
if (!isComplete && gathering?.accessKey) {
37-
trackPageView("view_page", {
36+
if (!isComplete && gathering) {
37+
trackViewPage({
3838
page_id: PAGE_ID,
3939
group_id: gathering.accessKey,
4040
});
4141
}
42-
}, [isComplete, gathering?.accessKey]);
42+
}, [isComplete, gathering]);
4343

4444
return (
4545
<>

src/pageComponents/landing/LandingPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
55
import { useEffect } from "react";
66
import { motion } from "motion/react";
77

8-
import { trackCtaClick, trackPageView } from "#/components/analytics";
8+
import { trackCtaClick, trackViewPage } from "#/components/analytics";
99
import { Layout } from "#/components/layout";
1010

1111
const PAGE_ID = "모임생성_랜딩";
@@ -19,7 +19,7 @@ export const LandingPage = () => {
1919
};
2020

2121
useEffect(() => {
22-
trackPageView("view_page", { page_id: PAGE_ID });
22+
trackViewPage({ page_id: PAGE_ID });
2323
}, []);
2424

2525
return (

0 commit comments

Comments
 (0)