feat: 새 기능 GA4 이벤트 — 창 열기·좋아요·댓글·신고·차단·약관 동의·이야기 글쓰기·히어로 오늘/내일·쇼츠·단풍 지도·내 각·토스 인트로·설치 띠 닫기

This commit is contained in:
minaChoi committed 2026-10-28 11:25:58 +09:00
1 parent 1489030c5f
commit 728b24a0c9
13 files changed
+110 -18

No files matched your search

+19 -1
View File
@@ -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` 타입에 먼저 더한다. 타입에 없는 이름은 빌드에서 걸린다.
+5
View File
@@ -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<HTMLDivElement>(null)
const mapShotRef = useRef<HTMLDivElement>(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<HTMLDivElement>(null)
const [box, setBox] = useState({ W: 0, H: 0 })
+6 -4
View File
@@ -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, readonly [string, string]> = {
[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,
},
)
+8 -3
View File
@@ -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]) => (
<button key={reason} type="button" disabled={pending} className={btn} onClick={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.'))}>
<button key={reason} type="button" disabled={pending} className={btn} onClick={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.', () => track('report', { content_type: 'comment', reason })))}>
{label}
</button>
))}
{step === 'block' && (
<>
<span className="w-full text-[13px] font-bold text-(--ink)">{c.nickname}님 댓글을 더는 안 볼까요?</span>
<button type="button" disabled={pending} className={cx(btn, 'bg-(--heart) text-white')} onClick={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.'))}>
<button type="button" disabled={pending} className={cx(btn, 'bg-(--heart) text-white')} onClick={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.', () => track('block', { content_type: 'comment' })))}>
차단하기
</button>
<button type="button" disabled={pending} className={btn} onClick={() => go('closed')}>
@@ -782,6 +784,7 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o
if (res.result?.success) {
setLiked(!!res.liked)
if (res.like_count != null) setCount(res.like_count)
if (next) track('like', { content_type: 'comment', item_id: c.comment_id })
return
}
revert()
@@ -883,6 +886,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
if (res.result?.desc === 'TERMS_REQUIRED') return setAskTerms(true)
setAddFailed(!res.result?.success)
if (!res.result?.success) return
track('comment', { post_id: postId })
setText('')
queryClient.invalidateQueries({ queryKey: listCommentsInfiniteQueryKey({ path: { post_id: postId } }) })
queryClient.invalidateQueries({ queryKey: getFeedQueryKey({ query: { region: region.code } }) })
@@ -905,6 +909,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
{
onSuccess: (res) => {
if (!res.result?.success) return setAddFailed(true)
track('terms_agree', {})
queryClient.setQueryData(meQueryKey(), res)
setAskTerms(false)
send()
+10 -1
View File
@@ -7,6 +7,7 @@ import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { CloseIcon } from './svg'
import { Rail, Skel, SkelRail, TAP44 } from './ui'
import { track } from '../lib/analytics'
// 유튜브는 플레이어가 200×200 이상이어야 해서, 카드 안 미리보기는 200px 너비로 띄우고 줄여 보인다.
// 위 로고·아래 제목 줄이 작은 카드에서 겹쳐 보이지 않게 가운데를 1.4배로 키워 위아래를 잘라 낸다
@@ -156,9 +157,16 @@ export function ShortsPage() {
const start = Math.max(0, items.findIndex((s) => s.id === firstId))
// 앱 안에서 들어왔으면 뒤로, 링크로 바로 들어왔으면 오늘 화면으로
const close = () => ((window.history.state as { idx?: number } | null)?.idx ? navigate(-1) : navigate('/', { replace: true }))
useEffect(() => {
if (firstId) track('shorts_open', { video_id: firstId })
}, [firstId])
const at = (s: ShortItem) => {
track('shorts_view', { video_id: s.id, index: items.indexOf(s) })
navigate(`/shorts/${s.id}`, { replace: true })
}
if (!items.length) return <div className="fixed inset-0 z-[70] bg-[#1d2233]" aria-busy={q.isPending} />
return <ShortsViewer items={items} start={start} onClose={close} onAt={(s) => navigate(`/shorts/${s.id}`, { replace: true })} />
return <ShortsViewer items={items} start={start} onClose={close} onAt={at} />
}
/**
@@ -300,6 +308,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
const on = !sound
soundRef.current = on
setSound(on)
track('shorts_sound', { on })
command(frames.current.get(at), on ? 'unMute' : 'mute')
}
+2
View File
@@ -36,6 +36,7 @@ import { DayShareCard, DayShareGrid, GakShareCard, type DayShare } from './share
import { CommentIcon, HeartIcon, SendIcon } from './svg'
import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui'
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText'
import { track } from '../lib/analytics'
type Mode = 'now' | TimeKind
@@ -334,6 +335,7 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
onClick={() => {
// 내일로 넘어갈 땐 지금 보던 시간대 그대로 시작해 배경이 튀지 않게
if (v && !tmr) setTmrKind(kind)
if (v !== tmr) track('hero_day_switch', { day: v ? 'tomorrow' : 'today' })
setTmr(v)
}}
className={cx('cursor-pointer rounded-full px-2.5 py-0.5 font-jua text-[13px]', tmr === v ? 'b-strip-on text-(--orange-deep)' : 'opacity-75')}
+6 -1
View File
@@ -1,4 +1,4 @@
import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
import { useNavigate } from 'react-router'
import { cx } from '../lib/utils'
import { useCarousel } from './carousel'
@@ -8,6 +8,7 @@ import { useSheet } from './sheetContext'
import { FoliageSpotShare } from './shareCards'
import { SendIcon } from './svg'
import { Ic } from './ui'
import { track } from '../lib/analytics'
const TAP_R = 24
const RANK_N = 7
@@ -37,6 +38,10 @@ export function FoliageCard() {
const labelAt = useMemo(() => placeLabels(pts, pts, size, { l: 0, t: 0, r: W, b: W }, [], () => true), [pts, size, W])
const provs = useMemo(() => placeProvinces(PROVINCES.map((v) => ({ name: v.name, x: v.x * W, y: v.y * W })), pts, labelBoxes(labelAt, size)), [pts, W, labelAt, size])
useEffect(() => {
if (picked) track('foliage_spot', { spot_name: picked, from: 'card' })
}, [picked])
if (!inSeason) return null
const go = (name?: string) => navigate(name ? `/foliage?spot=${encodeURIComponent(name)}` : '/foliage')
const toggle = (name: string) => setPicked(name === picked ? null : name)
+1
View File
@@ -32,6 +32,7 @@ export function InstallBanner() {
type="button"
onClick={() => {
dismiss()
track('install_banner_close', {})
setClosed(true)
}}
aria-label="닫기"
+12 -1
View File
@@ -7,6 +7,7 @@ import type { MyGakRule, MyGakScore } from '@nalssigak/shared/api/client/types.g
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { track } from '../lib/analytics'
const KEY = 'nalssigak.b.myRule'
@@ -121,7 +122,16 @@ export function useMyGak() {
const create = (g: MyGak, onDone?: () => void) => {
const item = { name: gakName(g.name), icon: g.icon, rule: g.rule }
if (loggedIn) {
add.mutate({ body: item }, { onSuccess: (res) => res.result?.success && onDone?.() })
add.mutate(
{ body: item },
{
onSuccess: (res) => {
if (!res.result?.success) return
track('my_gak_save', { gak_name: item.name })
onDone?.()
},
},
)
return
}
if (saved) {
@@ -129,6 +139,7 @@ export function useMyGak() {
return
}
setLocal(item)
track('my_gak_save', { gak_name: item.name })
onDone?.()
}
+6 -1
View File
@@ -2,6 +2,7 @@ import { useState } from 'react'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { likePostMutation, unlikePostMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import type { PostReaction, ResFeed } from '@nalssigak/shared/api/client/types.gen'
import { track } from '../lib/analytics'
export type PinnedKey = 'hero_post' | 'gak_post' | 'foliage_post' | 'events_post' | 'season_post'
@@ -29,7 +30,11 @@ export function usePinnedLike(key: PinnedKey, r?: PostReaction | null) {
;(on ? like : unlike).mutate(
{ path: { post_id: r.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: key, item_id: r.post_id })
},
onError: revert,
},
)
+12 -6
View File
@@ -21,6 +21,7 @@ import { topicName, TOPICS, useMyTalks } from './talkState'
import { useSheet } from './sheetContext'
import { CameraIcon, HeartIcon } from './svg'
import { Avatar, Rail, TAP44 } from './ui'
import { track } from '../lib/analytics'
const BODY_MAX = 100
const PHOTO_MAX = 10 * 1024 * 1024
@@ -106,6 +107,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
{
onSuccess: (res) => {
if (!res.result?.success) return setError(WRITE_ERRORS[res.result?.desc ?? ''] ?? '글을 올리지 못했어요. 다시 해 주세요.')
track('talk_post', { topic, with_image: !!image })
setText('')
setPhoto(null)
setTopic(TalkTopic.LOCAL)
@@ -216,7 +218,10 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
{ path: { talk_id: t.talk_id } },
{
onSuccess: (res) => {
if (res.result?.success && res.like_count != null) return setCount(res.like_count)
if (res.result?.success && res.like_count != null) {
if (next) track('like', { content_type: 'talk', item_id: t.talk_id })
return setCount(res.like_count)
}
setLiked(!next)
setCount(t.like_count)
},
@@ -229,14 +234,15 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
}
// 메뉴의 동작은 끝나면 목록을 다시 받아 숨긴 글·안 보기로 한 사람의 글이 빠지게 한다
const after = {
const after = (done?: () => void) => ({
onSuccess: (res: { result?: { success?: boolean } }) => {
if (!res.result?.success) return setFailed(true)
done?.()
setMenu('done')
refresh()
},
onError: () => setFailed(true),
}
})
const guard = (run: () => void) => (loggedIn ? run() : open({ type: 'login' }))
const src = t.image?.startsWith('/v1/') ? API_BASE_URL + t.image : (t.image ?? undefined)
@@ -272,7 +278,7 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
) : t.mine && menu === 'confirm' ? (
<>
<span className="self-center text-(--ink2)">지울까요?</span>
<button type="button" onClick={() => remove.mutate({ path: { talk_id: t.talk_id } }, { ...after, onSuccess: (res) => (after.onSuccess(res), res.result?.success && onGone?.()) })} disabled={remove.isPending} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
<button type="button" onClick={() => remove.mutate({ path: { talk_id: t.talk_id } }, after(() => onGone?.()))} disabled={remove.isPending} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
지우기
</button>
<button type="button" onClick={() => setMenu('closed')} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
@@ -285,13 +291,13 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
</button>
) : menu === 'report' ? (
REASONS.map(([reason, label]) => (
<button key={reason} type="button" onClick={() => report.mutate({ path: { talk_id: t.talk_id }, body: { reason } }, after)} disabled={report.isPending} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
<button key={reason} type="button" onClick={() => report.mutate({ path: { talk_id: t.talk_id }, body: { reason } }, after(() => track('report', { content_type: 'talk', reason })))} disabled={report.isPending} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
{label}
</button>
))
) : (
<>
<button type="button" onClick={() => guard(() => block.mutate({ path: { talk_id: t.talk_id } }, after))} disabled={block.isPending} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
<button type="button" onClick={() => guard(() => block.mutate({ path: { talk_id: t.talk_id } }, after(() => track('block', { content_type: 'talk' }))))} disabled={block.isPending} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
이 사람 글 안 보기
</button>
<button type="button" onClick={() => guard(() => setMenu('report'))} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
+2
View File
@@ -1,6 +1,7 @@
import { useState } from 'react'
import { IS_TOSS } from '../lib/platform'
import { Ic } from './ui'
import { track } from '../lib/analytics'
const KEY = 'nalssigak.b.tossIntroSeen'
@@ -29,6 +30,7 @@ export function TossIntro() {
} catch (e) {
console.warn('[intro] 본 기록을 저장하지 못함', e)
}
track('toss_intro_start', {})
setOpen(false)
}
+21
View File
@@ -1,3 +1,6 @@
import type { PinnedKey } from '../b/pinnedLike'
import type { SheetState } from '../b/sheetContext'
/** GA4로 보내는 이벤트와 값. 목록은 docs/이벤트_추적.md */
type Events = {
view_gak: { index_id: number; gak_name: string; score: number; rank: number }
@@ -11,8 +14,26 @@ type Events = {
install_choice: { outcome: 'accepted' | 'dismissed' }
install_done: Record<string, never>
app_launch: { mode: 'standalone' }
sheet_open: { sheet: SheetType }
like: { content_type: 'post' | 'comment' | 'talk' | PinnedKey; item_id: number }
comment: { post_id: number }
report: { content_type: 'comment' | 'talk'; reason: number }
block: { content_type: 'comment' | 'talk' }
terms_agree: Record<string, never>
talk_post: { topic: number; with_image: boolean }
hero_day_switch: { day: 'today' | 'tomorrow' }
shorts_open: { video_id: string }
shorts_view: { video_id: string; index: number }
shorts_sound: { on: boolean }
foliage_open: Record<string, never>
foliage_spot: { spot_name: string; from: 'page' | 'card' }
my_gak_save: { gak_name: string }
toss_intro_start: Record<string, never>
install_banner_close: Record<string, never>
}
type SheetType = Exclude<SheetState, null>['type']
declare global {
interface Window {
gtag?: (command: 'event', name: string, params: Record<string, unknown>) => void