Files
o2o-weather/frontend/src/lib/analytics.ts
T

21 lines
778 B
TypeScript

/** 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' }
sign_up: { method: 'id' }
region_change: { region_name: string; method: 'list' | 'location' }
}
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)
}