feat: 앱 GA4 이벤트 틀(track, 웹과 같은 이벤트 목록을 shared로) — 기존 앱 기능에 창_열기·각_보기·글_열기·로그인·지역_변경·좋아요·댓글·신고·차단·약관_동의·공유, 전송은 Firebase 연결 뒤. 탭 밖 화면용 루트 스택

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 16:52:08 +09:00
1 parent fcc7ed804c
commit cab3336859
20 files changed
+201 -110

No files matched your search

+6 -1
View File
@@ -13,6 +13,7 @@ import { LikeBurst } from '@/components/post/like-burst';
import { Dots, Pager } from '@/components/post/pager';
import { slideBg, SlideView, type Slide } from '@/components/post/slides';
import { Ic, Skel } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useAuth } from '@/lib/auth';
import { useSheet } from '@/lib/sheet';
import { shareView } from '@/lib/share-image';
@@ -157,7 +158,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,
},
);
+9 -1
View File
@@ -2,11 +2,12 @@ import { getArticleOptions, getSeasonWeekOptions } from '@nalssigak/shared/api/c
import { ARTICLE_LABEL, articleMeta, cardBg, dateRange, loadOf, shortDay } from '@nalssigak/shared/lib';
import { useQuery } from '@tanstack/react-query';
import { LinearGradient } from 'expo-linear-gradient';
import { useEffect } from 'react';
import { useEffect, useRef } from 'react';
import { Pressable, View } from 'react-native';
import { Text } from '@/components/text';
import { Credit, Ic, StateBox, Thumb } from '@/components/ui';
import { track } from '@/lib/analytics';
import { CARD_BG } from '@/lib/colors';
import { useSheet } from '@/lib/sheet';
import { useSky } from '@/lib/sky';
@@ -22,6 +23,13 @@ export function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitl
onTitle(a ? (ARTICLE_LABEL[a.category] ?? '') : '');
}, [a, onTitle]);
const tracked = useRef(0);
useEffect(() => {
if (!a || tracked.current === a.article_id) return;
tracked.current = a.article_id;
track('select_content', { content_type: 'article', item_id: a.article_id, category: ARTICLE_LABEL[a.category] ?? a.category });
}, [a]);
const load = loadOf(q);
if (!a) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="글을 찾지 못했어요." hold={<ArticleSkel />} boxClassName="inset-0" />}</Body>;
return (
+8 -3
View File
@@ -21,6 +21,7 @@ import { Text } from '@/components/text';
import { useCSSVariable } from 'uniwind';
import { Avatar, Skel, StateBox } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useAuth } from '@/lib/auth';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
@@ -59,9 +60,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 });
@@ -90,12 +92,12 @@ function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number;
)}
{step === 'report' &&
REPORT_REASONS.map(([reason, label]) => (
<Chip key={reason} label={label} disabled={pending} onPress={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.'))} />
<Chip key={reason} label={label} disabled={pending} onPress={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.', () => track('report', { content_type: 'comment', reason })))} />
))}
{step === 'block' && (
<>
<Text className="w-full text-[13px] font-bold text-ink">{c.nickname}님 댓글을 더는 안 볼까요?</Text>
<Chip label="차단하기" danger disabled={pending} onPress={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.'))} />
<Chip label="차단하기" danger disabled={pending} onPress={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.', () => track('block', { content_type: 'comment' })))} />
<Chip label="취소" disabled={pending} onPress={() => go('closed')} />
</>
)}
@@ -158,6 +160,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();
@@ -267,6 +270,7 @@ export function CommentsSheet({ postId, draft }: { postId: number; draft?: strin
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 } }) });
@@ -290,6 +294,7 @@ export function CommentsSheet({ postId, draft }: { postId: number; draft?: strin
onSuccess: (res) => {
if (!res.result?.success) return setAddFailed(true);
queryClient.setQueryData(meQueryKey(), res);
track('terms_agree', {});
setAskTerms(false);
send();
},
+10 -1
View File
@@ -3,12 +3,13 @@ import type { Factor, ResIndexDetail } from '@nalssigak/shared/api/client/types.
import { loadOf } from '@nalssigak/shared/lib';
import { useQuery } from '@tanstack/react-query';
import { LinearGradient } from 'expo-linear-gradient';
import { useEffect } from 'react';
import { useEffect, useRef } from 'react';
import { View } from 'react-native';
import { Text } from '@/components/text';
import Svg, { Circle, Line, Polygon, Text as SvgText, TSpan } from 'react-native-svg';
import { Ic, Skel, StateBox } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useRegion } from '@/lib/region';
import { useSky } from '@/lib/sky';
@@ -110,6 +111,14 @@ export function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: s
onTitle(g ? `${g.rank}위 ${g.name}` : '계산 근거');
}, [g, onTitle]);
// 지역이 바뀌어 다시 받아도 한 번만 보낸다
const tracked = useRef(0);
useEffect(() => {
if (!g || tracked.current === g.index_id) return;
tracked.current = g.index_id;
track('view_gak', { index_id: g.index_id, gak_name: g.name, score: g.score, rank: g.rank });
}, [g]);
const load = loadOf(q);
if (!g) return <Body>{load === 'loading' ? <GakSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이 각의 계산 근거가 아직 없어요." hold={<GakSkel />} boxClassName="inset-0" />}</Body>;
const factors = d.factors ?? [];
+5 -1
View File
@@ -5,6 +5,7 @@ import { Text } from '@/components/text';
import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { track } from '@/lib/analytics';
import { SheetContext, useSheet, type SheetState } from '@/lib/sheet';
import { ArticleSheet, SeasonWeekSheet } from './article';
@@ -16,7 +17,10 @@ import { RegionSheet } from './region';
export function SheetProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<SheetState>(null);
const open = useCallback((s: Exclude<SheetState, null>) => setState(s), []);
const open = useCallback((s: Exclude<SheetState, null>) => {
track('sheet_open', { sheet: s.type });
setState(s);
}, []);
const close = useCallback(() => setState(null), []);
const api = useMemo(() => ({ open, close }), [open, close]);
+2
View File
@@ -4,6 +4,7 @@ import { useState } from 'react';
import { Pressable } from 'react-native';
import { Text } from '@/components/text';
import { track } from '@/lib/analytics';
import { useAuth } from '@/lib/auth';
import { GoogleButton } from './google';
@@ -20,6 +21,7 @@ export function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLogge
return;
}
setTokens(res.access_token, res.refresh_token ?? null);
track(res.is_new ? 'sign_up' : 'login', { method: 'google' });
onLoggedIn();
};
const fail = () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.');
+2
View File
@@ -6,6 +6,7 @@ import { Pressable, View } from 'react-native';
import { Text } from '@/components/text';
import { Skel, StateBox } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useAuth } from '@/lib/auth';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
@@ -66,6 +67,7 @@ export function RegionSheet({ onDone }: { onDone: () => void }) {
accessibilityState={{ selected: here }}
onPress={() => {
setRegion(r);
track('region_change', { region_name: r.name, method: 'list' });
onDone();
}}
className="flex-row items-center justify-between border-b-[1.5px] border-line px-1 py-3"