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

+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)
}