61 lines
2.7 KiB
TypeScript
61 lines
2.7 KiB
TypeScript
import type { PinnedKey } from '../b/pinnedLike'
|
|
import type { Holiday } from '../b/holiday'
|
|
import type { SheetState } from '../b/sheetContext'
|
|
|
|
/** GA4로 보내는 이벤트와 값. 목록은 docs/이벤트_추적.md */
|
|
type Events = {
|
|
view_gak: { index_id: number; gak_name: string; score: number; rank: number }
|
|
select_content: { content_type: 'article'; item_id: number; category: string }
|
|
share: { content_type: 'image'; item_id: string; method: 'share_sheet' | 'download'; ratio: string }
|
|
login: { method: 'id' | 'google' | 'toss' }
|
|
sign_up: { method: 'id' }
|
|
region_change: { region_name: string; method: 'list' | 'location' }
|
|
install_banner_view: Record<string, never>
|
|
install_click: { from: 'banner' | 'menu'; method: 'prompt' | 'guide' }
|
|
install_choice: { outcome: 'accepted' | 'dismissed' }
|
|
install_done: Record<string, never>
|
|
app_launch: { mode: 'standalone' }
|
|
/** index.html 첫 화면 스크립트가 gtag 로 바로 보낸다 */
|
|
boot_stuck: { reason: string; seconds: number; tries: number; app_started: boolean }
|
|
sheet_open: { sheet: SheetType }
|
|
like: { content_type: 'post' | 'comment' | 'talk' | PinnedKey; item_id: number }
|
|
comment: { post_id: number }
|
|
talk_comment: { talk_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 }
|
|
feed_item_view: { item_type: 'talk' | 'event'; position: number }
|
|
hero_day_switch: { day: 'today' | 'tomorrow' }
|
|
tomorrow_to_today: { region_name: string }
|
|
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 }
|
|
fortune_draw: { card: string }
|
|
day_log: { mood: number; went_out: boolean; card_hit: boolean | null }
|
|
today_icon: { icon: string }
|
|
saju_input: { with_time: boolean }
|
|
saju_view: { scene: string; score: number; strength: string; top_element: string }
|
|
game_start: { again: boolean; logged_in: boolean; wind_ms: number; theme: 'basic' | Holiday['key'] }
|
|
game_round: { round: number; score: number; logged_in: boolean }
|
|
game_over: { round: number; score: number; best: boolean; drops: number }
|
|
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
|
|
}
|
|
}
|
|
|
|
export function track<E extends keyof Events>(event: E, params: Events[E]) {
|
|
if (import.meta.env.DEV) return
|
|
window.gtag?.('event', event, params)
|
|
}
|