Skip to content

Commit 70df0f9

Browse files
authored
Merge pull request #123 from Team-Senifit/release-1.0.1
GTM 1차 수정
2 parents 22f8599 + 6eeb55f commit 70df0f9

File tree

9 files changed

+40
-16
lines changed

9 files changed

+40
-16
lines changed

src/app/(plain)/exercise/class/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Page = () => {
2323
else if (!selectedProgram) {
2424
router.push("/");
2525
} else if (!startFired.current) {
26-
pushGtmEvent("click_Start", getGtmClassType(type));
26+
pushGtmEvent("class_Start", getGtmClassType(type));
2727
startFired.current = true;
2828
}
2929
return () => {};

src/app/(plain)/exercise/class/[id]/panel/WorkoutVideoPlayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default function WorkoutVideoPlaylist({
168168
useEffect(() => {
169169
const halfDuration = Math.floor(duration * 30);
170170
if (!progressFired.current && seconds >= halfDuration && halfDuration > 0) {
171-
pushGtmEvent("click_Progress", getGtmClassType(type));
171+
pushGtmEvent("class_Progress", getGtmClassType(type));
172172
progressFired.current = true;
173173
}
174174
}, [seconds, duration, type]);

src/app/(with-container)/(exercise)/exercise/done/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Page = () => {
4040
useEffect(() => {
4141
mutate();
4242
if (selectedProgram && seconds >= selectedProgram.duration * 60) {
43-
pushGtmEvent("click_Finish", getGtmClassType(type));
43+
pushGtmEvent("class_Finish", getGtmClassType(type));
4444
}
4545
}, [mutate, selectedProgram, seconds, type]);
4646

src/app/(with-container)/(exercise)/panel/ThematicRoutine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const ThematicRoutine = ({ authenticated }: { authenticated: boolean }) => {
1010
const { isPhone } = useMedia();
1111
return (
1212
<Button
13-
id={"Click_Topic"}
13+
id={"click_Topic"}
1414
fullWidth
1515
component={Link}
1616
href={

src/app/(with-container)/record/panel/SurveyActionButton.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Elder, ElderUpdatePayload } from "./SurveyElderCard";
99
import { axiosClient } from "@/apis/axiosClient";
1010
import { isAuthError } from "@/apis/errors";
1111
import SenifitDialog from "@/components/SenifitDialog";
12+
import { getGtmClassTypeFromRoutineKind, pushGtmEvent } from "@/utils/gtm";
1213

1314
type Mode = "write" | "detail" | "update";
1415
type ConfirmKind = null | "editConfirm" | "saveConfirm";
@@ -30,6 +31,7 @@ type Props = {
3031
gap?: number;
3132
alignRight?: boolean;
3233
mobileStepper?: StepperProps;
34+
routineKind?: string;
3335
};
3436

3537
export default function SurveyActionButton({
@@ -41,6 +43,7 @@ export default function SurveyActionButton({
4143
gap = 2,
4244
alignRight = true,
4345
mobileStepper,
46+
routineKind,
4447
}: Props) {
4548
const router = useRouter();
4649
const qc = useQueryClient();
@@ -90,6 +93,10 @@ export default function SurveyActionButton({
9093
await axiosClient.put(`/records/${recordId}/surveys`, payload);
9194
},
9295
onSuccess: () => {
96+
pushGtmEvent(
97+
"record_Finish",
98+
getGtmClassTypeFromRoutineKind(routineKind),
99+
);
93100
qc.invalidateQueries({ queryKey: ["surveys", recordId] });
94101
router.push(afterSaveHref);
95102
},

src/app/(with-container)/record/panel/SurveySection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export default function SurveySection({ recordId, mode }: Props) {
5858
);
5959

6060
// GET
61-
const { data: elders = [] } = useSuspenseQuery<Elder[]>({
61+
const {
62+
data: { elders, routineKind } = { elders: [], routineKind: undefined },
63+
} = useSuspenseQuery<{ elders: Elder[]; routineKind?: string }>({
6264
queryKey: ["surveys", recordId],
6365
queryFn: async () => {
6466
// 서버 환경(SSR)에서 상대 경로 fetch가 실패하는 문제를 해결하기 위해 BASE_URL 처리
@@ -77,6 +79,8 @@ export default function SurveySection({ recordId, mode }: Props) {
7779

7880
console.log("GET /api/records/" + recordId + "/surveys response:", json);
7981

82+
const routineKind = json?.data?.record?.routineKind;
83+
8084
const reverseTroublePartMap: Record<string, string> = {
8185
workout_kinds_calisthenic_targets_shoulders: "어깨",
8286
workout_kinds_calisthenic_targets_arms: "팔",
@@ -85,7 +89,7 @@ export default function SurveySection({ recordId, mode }: Props) {
8589
workout_kinds_calisthenic_targets_abs: "배",
8690
};
8791

88-
const surveys = (json?.data?.surveys ?? []).map((s: unknown) => {
92+
const surveyList = (json?.data?.surveys ?? []).map((s: unknown) => {
8993
const raw = s as {
9094
troubleParts?: (string | { target: string })[];
9195
memo?: string;
@@ -106,7 +110,7 @@ export default function SurveySection({ recordId, mode }: Props) {
106110
};
107111
});
108112

109-
return surveys as Elder[];
113+
return { elders: surveyList as Elder[], routineKind };
110114
},
111115
});
112116

@@ -253,6 +257,7 @@ export default function SurveySection({ recordId, mode }: Props) {
253257
mode={mode}
254258
elders={elders}
255259
pending={pending}
260+
routineKind={routineKind}
256261
afterSaveHref={"/record"}
257262
mobileStepper={
258263
isPhone

src/app/layout.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import timezone from "dayjs/plugin/timezone";
88
import QueryProviders from "./panel/QueryClientProvider";
99
import LoadingFallback from "./panel/LoadingFallback";
1010
import Toast from "@/components/Toast";
11-
import Script from "next/script";
11+
// import Script from "next/script";
1212

1313
// dayjs locale 설정, time zone 설정
1414
dayjs.locale("ko");
@@ -58,9 +58,8 @@ export default function RootLayout({
5858
<html lang={"ko"}>
5959
<head>
6060
{/* Google Tag Manager */}
61-
<Script
62-
id={"google-tag-manager"}
63-
strategy={"afterInteractive"}
61+
{/* eslint-disable-next-line @next/next/next-script-for-ga */}
62+
<script
6463
dangerouslySetInnerHTML={{
6564
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
6665
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

src/components/Carousel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Carousel = <T,>({
4848
<Box ref={containerRef} sx={{ position: "relative", overflow: "hidden" }}>
4949
{/* 이전 버튼 */}
5050
<IconButton
51-
id={"click_click_Carousel"}
51+
id={"click_Carousel"}
5252
sx={{
5353
...iconButtonStyle,
5454
left: "1rem",
@@ -65,7 +65,7 @@ const Carousel = <T,>({
6565

6666
{/* 다음 버튼 */}
6767
<IconButton
68-
id={"click_click_Carousel"}
68+
id={"click_Carousel"}
6969
sx={{
7070
...iconButtonStyle,
7171
right: "1rem",

src/utils/gtm.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export type GTM_EVENT_TYPE =
22
| "click_classStart"
3-
| "click_Start"
4-
| "click_Progress"
3+
| "class_Start"
4+
| "class_Progress"
55
| "click_classStop"
6-
| "click_Finish"
6+
| "class_Finish"
77
| "record_Finish"
88
| "login_Success"
99
| "customized_optionError";
@@ -43,3 +43,16 @@ export const getGtmClassType = (type: unknown) => {
4343
if (Array.isArray(type) && type[0] === "thematic") return "주제별";
4444
return undefined;
4545
};
46+
47+
export const getGtmClassTypeFromRoutineKind = (routineKind?: string) => {
48+
switch (routineKind) {
49+
case "workout_programs_selections_byPopular":
50+
return "인기";
51+
case "workout_programs_selections_byPersonal":
52+
return "맞춤형";
53+
case "workout_programs_selections_byTarget":
54+
return "주제별";
55+
default:
56+
return undefined;
57+
}
58+
};

0 commit comments

Comments
 (0)