From 728b24a0c9974617588f62fa60aea1f6f5b4907f Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Wed, 28 Oct 2026 11:25:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=88=20=EA=B8=B0=EB=8A=A5=20GA4=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=E2=80=94=20=EC=B0=BD=20=EC=97=B4?= =?UTF-8?q?=EA=B8=B0=C2=B7=EC=A2=8B=EC=95=84=EC=9A=94=C2=B7=EB=8C=93?= =?UTF-8?q?=EA=B8=80=C2=B7=EC=8B=A0=EA=B3=A0=C2=B7=EC=B0=A8=EB=8B=A8=C2=B7?= =?UTF-8?q?=EC=95=BD=EA=B4=80=20=EB=8F=99=EC=9D=98=C2=B7=EC=9D=B4=EC=95=BC?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=80=EC=93=B0=EA=B8=B0=C2=B7=ED=9E=88=EC=96=B4?= =?UTF-8?q?=EB=A1=9C=20=EC=98=A4=EB=8A=98/=EB=82=B4=EC=9D=BC=C2=B7?= =?UTF-8?q?=EC=87=BC=EC=B8=A0=C2=B7=EB=8B=A8=ED=92=8D=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=C2=B7=EB=82=B4=20=EA=B0=81=C2=B7=ED=86=A0=EC=8A=A4=20=EC=9D=B8?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=C2=B7=EC=84=A4=EC=B9=98=20=EB=9D=A0=20?= =?UTF-8?q?=EB=8B=AB=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/이벤트_추적.md | 20 +++++++++++++++++++- frontend/src/b/FoliagePage.tsx | 5 +++++ frontend/src/b/Post.tsx | 10 ++++++---- frontend/src/b/Sheets.tsx | 11 ++++++++--- frontend/src/b/Shorts.tsx | 11 ++++++++++- frontend/src/b/TodayPage.tsx | 2 ++ frontend/src/b/foliageMap.tsx | 7 ++++++- frontend/src/b/installBanner.tsx | 1 + frontend/src/b/myGakState.ts | 13 ++++++++++++- frontend/src/b/pinnedLike.ts | 7 ++++++- frontend/src/b/talk.tsx | 18 ++++++++++++------ frontend/src/b/tossIntro.tsx | 2 ++ frontend/src/lib/analytics.ts | 21 +++++++++++++++++++++ 13 files changed, 110 insertions(+), 18 deletions(-) diff --git a/docs/이벤트_추적.md b/docs/이벤트_추적.md index 9aec8c6..9700c66 100644 --- a/docs/이벤트_추적.md +++ b/docs/이벤트_추적.md @@ -1,6 +1,6 @@ # 이벤트 추적 (GA4) -기준: `frontend/index.html`, `frontend/src/lib/analytics.ts`, `frontend/src/b/Sheets.tsx`, `frontend/src/b/region.tsx`, `frontend/src/b/install.ts`, `frontend/src/b/installBanner.tsx`, `frontend/src/main.tsx` (2026-10-21) +기준: `frontend/index.html`, `frontend/src/lib/analytics.ts`, `frontend/src/b/Sheets.tsx`, `frontend/src/b/region.tsx`, `frontend/src/b/install.ts`, `frontend/src/b/installBanner.tsx`, `frontend/src/main.tsx`, 2026-10-28 추가분은 `Post.tsx`·`pinnedLike.ts`·`talk.tsx`·`TodayPage.tsx`·`Shorts.tsx`·`FoliagePage.tsx`·`foliageMap.tsx`·`myGakState.ts`·`tossIntro.tsx` (2026-10-21, 2026-10-28) ## 한 줄 요약 @@ -34,8 +34,26 @@ GA4 태그(`gtag.js`, 측정 ID `G-D378J4X373`)를 `index.html`에 심고, 화 | `install_choice` | 설치창에서 고름 (안드로이드·PC Chrome·Edge) | `outcome: 'accepted' \| 'dismissed'` | `install.ts` `promptInstall` | | `install_done` | 설치 완료 (브라우저가 `appinstalled`를 줄 때만. 아이폰은 오지 않음) | 없음 | `install.ts` | | `app_launch` | 홈 화면 아이콘(설치한 앱)으로 엶 | `mode: 'standalone'` | `main.tsx` | +| `sheet_open` | 아래에서 올라오는 창이 열림 (각·글·보내기·댓글·로그인·내 정보·지역·내 각·홈 화면 추가·점수 근거·이야기 등) | `sheet`(창 종류: `gak`·`article`·`share`·`comments`·`login`·`me`·`region`·`mix`·`myGak`·`install`·`weatherWhy`·`talk`·`seasonWeek`) | `Sheets.tsx` `SheetProvider` `open` | +| `like` | 좋아요 성공 (취소는 안 보냄) | `content_type: 'post' \| 'comment' \| 'talk' \| 'hero_post' \| 'gak_post' \| 'foliage_post' \| 'events_post' \| 'season_post'`, `item_id`(포스트·댓글·글 번호) | `Post.tsx` `FullCard`, `pinnedLike.ts`, `Sheets.tsx` `CommentRow`, `talk.tsx` | +| `comment` | 댓글 올리기 성공 | `post_id` | `Sheets.tsx` `CommentsSheet` `send` | +| `terms_agree` | 댓글 쓰기 전 이용약관 동의 성공 | 없음 | `Sheets.tsx` `CommentsSheet` `agreeAndSend` | +| `report` | 신고 성공 | `content_type: 'comment' \| 'talk'`, `reason`(신고 이유 번호) | `Sheets.tsx` `CommentMenu`, `talk.tsx` | +| `block` | 차단 성공 | `content_type: 'comment' \| 'talk'` | `Sheets.tsx` `CommentMenu`, `talk.tsx` | +| `talk_post` | 이야기 글 올리기 성공 | `topic`(주제 번호), `with_image` | `talk.tsx` 글쓰기 `submit` | +| `hero_day_switch` | 히어로 오늘/내일 스위치를 바꿈 | `day: 'today' \| 'tomorrow'` | `TodayPage.tsx` | +| `shorts_open` | 쇼츠 페이지(/shorts/영상ID)로 들어옴 (오늘 화면 쇼츠 줄·공유 링크) | `video_id` | `Shorts.tsx` `ShortsPage` | +| `shorts_view` | 쇼츠를 넘겨 다른 영상으로 감 | `video_id`, `index`(목록 순서) | `Shorts.tsx` `ShortsPage` | +| `shorts_sound` | 쇼츠 소리 켜기·끄기 | `on` | `Shorts.tsx` `toggleSound` | +| `foliage_open` | 단풍 지도 페이지(/foliage)를 엶 | 없음 | `FoliagePage.tsx` | +| `foliage_spot` | 단풍 명소를 고름 | `spot_name`, `from: 'page' \| 'card'`(지도 페이지·오늘 화면 카드) | `FoliagePage.tsx`, `foliageMap.tsx` | +| `my_gak_save` | 내 각 만들기 성공 (로그인 전엔 기기에 저장) | `gak_name` | `myGakState.ts` `create` | +| `toss_intro_start` | 토스판 첫 소개 화면에서 '시작하기' | 없음 | `tossIntro.tsx` | +| `install_banner_close` | '홈 화면에 추가' 띠를 × 로 닫음 | 없음 | `installBanner.tsx` | - 공유창에서 사용자가 취소하면 `share`를 보내지 않는다. +- 토스판은 로그인이 없어 `login` `toss`는 나가지 않는다. `id`·`sign_up`도 지금 화면에 아이디 가입이 없어 나가지 않는다. +- 점수 근거·댓글창 열기처럼 창으로 여는 기능은 따로 이벤트를 두지 않고 `sheet_open`의 `sheet`로 나눠 본다. - `region_change`의 `location`은 처음 온 사람의 자동 위치 맞춤도 포함한다. - 설치는 카드 노출 → 누름 → 설치 완료 → 홈 화면 실행 순서로 본다. 아이폰은 설치 완료를 알 수 없어 `app_launch`로 대신 본다. - 새 이벤트는 `analytics.ts`의 `Events` 타입에 먼저 더한다. 타입에 없는 이름은 빌드에서 걸린다. diff --git a/frontend/src/b/FoliagePage.tsx b/frontend/src/b/FoliagePage.tsx index b88ef90..0461ae1 100644 --- a/frontend/src/b/FoliagePage.tsx +++ b/frontend/src/b/FoliagePage.tsx @@ -6,6 +6,7 @@ import { useSheet } from './sheetContext' import { FoliageMapShare, FoliageSpotShare } from './shareCards' import { SendIcon } from './svg' import { Chips, Ic, TAP44 } from './ui' +import { track } from '../lib/analytics' type View = { s: number; tx: number; ty: number } type Filter = 'all' | Kind @@ -66,6 +67,10 @@ export function FoliagePage() { const spotShotRef = useRef(null) const mapShotRef = useRef(null) const shown = useMemo(() => spots.filter((m) => filter === 'all' || m.kind === filter), [spots, filter]) + useEffect(() => track('foliage_open', {}), []) + useEffect(() => { + if (sel) track('foliage_spot', { spot_name: sel, from: 'page' }) + }, [sel]) const vpRef = useRef(null) const [box, setBox] = useState({ W: 0, H: 0 }) diff --git a/frontend/src/b/Post.tsx b/frontend/src/b/Post.tsx index 4de2add..6bbfe80 100644 --- a/frontend/src/b/Post.tsx +++ b/frontend/src/b/Post.tsx @@ -15,6 +15,7 @@ import { CommentIcon, HeartIcon, SendIcon } from './svg' import { useCarousel } from './carousel' import { MoonArt } from './moon' import { Arrows, Credit, Ic, Rows, Skel, TAP44, Thumb } from './ui' +import { track } from '../lib/analytics' const ACCOUNTS: Record = { [PostType.WEATHER]: ['오늘 날씨', 'sun'], @@ -416,10 +417,11 @@ function FullCard({ post }: PostProps) { ;(on ? like : unlike).mutate( { path: { post_id: post.post_id } }, { - onSuccess: (res) => - res.result?.success - ? patch({ liked: res.liked ?? on, ...(res.like_count != null ? { like_count: res.like_count } : {}) }) - : revert(), + onSuccess: (res) => { + if (!res.result?.success) return revert() + patch({ liked: res.liked ?? on, ...(res.like_count != null ? { like_count: res.like_count } : {}) }) + if (on) track('like', { content_type: 'post', item_id: post.post_id }) + }, onError: revert, }, ) diff --git a/frontend/src/b/Sheets.tsx b/frontend/src/b/Sheets.tsx index 67d0cc6..1a22312 100644 --- a/frontend/src/b/Sheets.tsx +++ b/frontend/src/b/Sheets.tsx @@ -54,6 +54,7 @@ export function SheetProvider({ children }: { children: ReactNode }) { window.history.pushState({ ...window.history.state, sheet: true }, '') pushed.current = true } + track('sheet_open', { sheet: s.type }) setState(s) }, []) const close = useCallback(() => { @@ -692,9 +693,10 @@ function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number; const block = useMutation(blockAuthorMutation()) const pending = report.isPending || block.isPending - const finish = (notice: string) => ({ + const finish = (notice: string, done: () => void) => ({ onSuccess: (res: { result?: { success?: boolean } }) => { if (!res.result?.success) return setFailed(true) + done() setStep('closed') onNotice(notice) queryClient.invalidateQueries({ predicate: isCommentList }) @@ -728,14 +730,14 @@ function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number; )} {step === 'report' && REPORT_REASONS.map(([reason, label]) => ( - ))} {step === 'block' && ( <> {c.nickname}님 댓글을 더는 안 볼까요? - ) : menu === 'report' ? ( REASONS.map(([reason, label]) => ( - )) ) : ( <> -