Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

on:
push:
branches:
- main
pull_request:
types:
- closed
Expand Down
22 changes: 0 additions & 22 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"classnames": "^2.5.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-gtm-module": "^2.0.11",
"react-router-dom": "^7.1.3",
"zustand": "^5.0.3"
},
Expand All @@ -47,7 +46,6 @@
"@types/node": "^22.10.7",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@types/react-gtm-module": "^2",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"@vitejs/plugin-react": "^4.3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/common/useChannelTalk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useChannelTalk = () => {
ChannelService.loadScript();

ChannelService.boot({
pluginKey: import.meta.env.VITE_CHANNEL_TALK_KEY || "",
pluginKey: import.meta.env.VITE_CHANNEL_TALK || "",
hideChannelButtonOnBoot: true,
});
}, []);
Expand Down
38 changes: 16 additions & 22 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { StrictMode } from "react";
import ReactDom from "react-dom/client";
import TagManager from "react-gtm-module";

import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

Expand All @@ -17,33 +16,28 @@ import { ToastProvider } from "@/hooks/common/useToast";
import "@/styles/reset.scss";
import "@/styles/global.scss";

const gtmTag = {
gtmId: import.meta.env.VITE_GTM_ID,
};

const initializeGA4 = () => {
const ga4Id = import.meta.env.VITE_GA4_ID;

const script = document.createElement("script");
script.async = true;
script.src = `https://www.googletagmanager.com/gtag/js?id=${ga4Id}`;
document.head.appendChild(script);
const GA4_ID = import.meta.env.VITE_GA4_ID;

script.onload = () => {
(window as any).dataLayer = (window as any).dataLayer || [];
const addGtagScript = () => {
if (!GA4_ID) return;

(window as any).gtag = function (...args: any[]) {
(window as any).dataLayer.push(args);
};
const script1 = document.createElement("script");
script1.src = `https://www.googletagmanager.com/gtag/js?id=${GA4_ID}`;
script1.async = true;
document.head.appendChild(script1);

(window as any).gtag("js", new Date());
(window as any).gtag("config", ga4Id);
};
const script2 = document.createElement("script");
script2.innerHTML = `
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '${GA4_ID}');
`;
document.head.appendChild(script2);
};

if (import.meta.env.MODE === "production") {
TagManager.initialize(gtmTag);
initializeGA4();
addGtagScript();
}

ReactDom.createRoot(document.getElementById("root")!).render(
Expand Down
5 changes: 4 additions & 1 deletion src/pages/CreateReviewFailPage/CreateReviewFailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const CreateReviewFailPage = () => {
const { resetScanData } = useScanDataStore();

const handleNavigateHome = () => {
gTagLogEvent("create_review_fail_home_button");
gTagLogEvent("create_review_fail_home_button_click", {
category: "Button",
label: "create_review_fail_home_button",
});
resetGenerateReviewData();
resetCreateReviewData();
resetScanData();
Expand Down
15 changes: 12 additions & 3 deletions src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ const HomePage = () => {
<button
className={styles.ShareButton}
onClick={() => {
gTagLogEvent("share_button");
gTagLogEvent("share_button_click", {
category: "Button",
label: "share_button",
});

send({ type: AppBridgeMessageType.SHARE, payload: { shareText: getShareText() } });
}}
Expand Down Expand Up @@ -89,7 +92,10 @@ const HomePage = () => {
text="갤러리"
iconName="gallery"
onClick={() => {
gTagLogEvent("gallery_button");
gTagLogEvent("gallery_button_click", {
category: "Button",
label: "gallery_button",
});

send({ type: AppBridgeMessageType.OPEN_GALLERY, payload: "" });

Expand All @@ -100,7 +106,10 @@ const HomePage = () => {
text="카메라"
iconName="camera"
onClick={() => {
gTagLogEvent("camera_button");
gTagLogEvent("camera_button_click", {
category: "Button",
label: "camera_button",
});

send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });

Expand Down
5 changes: 4 additions & 1 deletion src/pages/LoadingPage/LoadingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const LoadingPage = () => {
const { resetScanData } = useScanDataStore();

const handleNavigateToHome = () => {
gTagLogEvent("loading_close_button");
gTagLogEvent("loading_close_button_click", {
category: "Button",
label: "loading_close_button",
});

resetGenerateReviewData();
resetCreateReviewData();
Expand Down
10 changes: 8 additions & 2 deletions src/pages/ReceiptEditPage/ReceiptEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const ReceiptEditPage = () => {
<Navbar>
<Navbar.LeftButton
onClick={() => {
gTagLogEvent("receipt_edit_home_button");
gTagLogEvent("receipt_edit_home_button_click", {
category: "Button",
label: "receipt_edit_home_button",
});

handleNavigateToHome();
}}
Expand Down Expand Up @@ -141,7 +144,10 @@ const ReceiptEditPage = () => {
text="다시 스캔하기"
variant="secondary"
onClick={() => {
gTagLogEvent("receipt_edit_rescan_button");
gTagLogEvent("receipt_edit_rescan_button_click", {
category: "Button",
label: "receipt_edit_rescan_button",
});

handleNavigateToHome();
}}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/ReceiptInputPage/ReceiptInputPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ const ReceiptInputPage = () => {
};

const handleHomeClick = () => {
gTagLogEvent("receipt_input_back_button");
gTagLogEvent("receipt_input_back_button_click", {
category: "Button",
label: "receipt_input_back_button",
});
resetScanData();
navigateToHome();
};
Expand Down
17 changes: 14 additions & 3 deletions src/pages/RecognitionFailPage/RecognitionFailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ const RecognitionFailPage = () => {
const { resetScanData } = useScanDataStore();

const handleNavigateToHome = () => {
gTagLogEvent("recognition_fail_close_button");
gTagLogEvent("recognition_fail_close_button_click", {
category: "Button",
label: "recognition_fail_close_button",
});

resetScanData();
navigateToHome();
};

const handleNavgateToReceiptInput = () => {
gTagLogEvent("receipt_input_button");
gTagLogEvent("receipt_input_button_click", {
category: "Button",
label: "receipt_input_button",
});

resetScanData();
navgateToReceiptInput();
};
Expand Down Expand Up @@ -58,7 +66,10 @@ const RecognitionFailPage = () => {
text="다시 촬영하기"
variant="secondary"
onClick={() => {
gTagLogEvent("camera_retry_button");
gTagLogEvent("camera_retry_button_click", {
category: "Button",
label: "camera_retry_button",
});

send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });
}}
Expand Down
15 changes: 12 additions & 3 deletions src/pages/ReviewResultPage/ReviewResultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export default function ReviewResultPage() {
};

const handleRetryCreateReview = () => {
gTagLogEvent("review_retry_button");
gTagLogEvent("review_retry_button_click", {
category: "Button",
label: "review_retry_button",
});

resetGenerateReviewData();

Expand Down Expand Up @@ -92,7 +95,10 @@ export default function ReviewResultPage() {
iconName="paste"
size="sm"
onClick={() => {
gTagLogEvent("copy_button");
gTagLogEvent("copy_button_click", {
category: "Button",
label: "copy_button",
});

send({ type: AppBridgeMessageType.COPY, payload: { review: generateReviewData } });

Expand All @@ -106,7 +112,10 @@ export default function ReviewResultPage() {
<Button
text="홈으로 가기"
onClick={() => {
gTagLogEvent("home_button");
gTagLogEvent("home_button_click", {
category: "Button",
label: "home_button",
});
handleOpen();
}}
/>
Expand Down
17 changes: 14 additions & 3 deletions src/pages/SelectStylePage/SelectStylePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ const SelectStylePage = () => {
};

const handleCreateReview = () => {
gTagLogEvent("create_review_button");
gTagLogEvent("create_review_button_click", {
category: "Button",
label: "create_review_button",
});

const mappedStyle = STYLE_NAME_MAPPING[selectedStyle.name];

Expand Down Expand Up @@ -92,7 +95,11 @@ const SelectStylePage = () => {
<div className={styles.ExampleButtonBox}>
<button
onClick={() => {
gTagLogEvent("style_example_button");
gTagLogEvent("style_example_button_click", {
category: "Button",
label: "style_example_button",
});

handleOpen();
}}
>
Expand All @@ -116,7 +123,11 @@ const SelectStylePage = () => {
[styles.isSelected]: selectedStyle.name === style.name,
})}
onClick={() => {
gTagLogEvent(style.tagId);
gTagLogEvent(`${style.tagId}_click`, {
category: "Button",
label: `${style.tagId}`,
});

handleStyleClick(style);
}}
>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/SelectTagPage/SelectTagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ const SelectTagPage = () => {
<Tag
variant="add"
onClick={() => {
gTagLogEvent("add_tag_button");
gTagLogEvent("add_tag_button_click", {
category: "Button",
label: "add_tag_button",
});

setIsBottomSheetOpen(true);
}}
/>
Expand Down
12 changes: 3 additions & 9 deletions src/utils/gtag.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export const gTagLogEvent = (eventLabel: string) => {
if (typeof window !== "undefined" && typeof window.gtag === "function") {
window.gtag("event", "click", {
event_category: "button",
event_label: eventLabel,
});
} else {
console.warn("Google Analytics is not initialized yet.");
}
export const gTagLogEvent = (eventName: string, eventParams: object = {}) => {
if (!window.gtag) return;
window.gtag("event", eventName, eventParams);
};
Loading
Loading