learning_ai_clock/web/src/lib/analytics.ts

30 lines
1.2 KiB
TypeScript

// ── Analytics ────────────────────────────────────────────────────
// Forwards events to platform-service telemetry client.
// Keeps the same public API so existing callers (store.ts, InstallPrompt) are unchanged.
import { trackTimerEvent, trackEvent } from './telemetry';
export function trackTimerCreated(type: 'alarm' | 'countdown' | 'pomodoro' | 'event', urgency: string, cascade: string): void {
trackTimerEvent('timer_created', { type, urgency, cascade });
}
export function trackTimerCompleted(type: string, durationMs: number): void {
trackTimerEvent('timer_completed', { type }, { durationMs });
}
export function trackCascadeFired(timerId: string, minutesBefore: number): void {
trackTimerEvent('cascade_fired', { timerId }, { minutesBefore });
}
export function trackPomodoroCompleted(rounds: number, totalMinutes: number): void {
trackTimerEvent('pomodoro_completed', undefined, { rounds, totalMinutes });
}
export function trackPWAInstalled(): void {
trackEvent('info', 'pwa', 'pwa_installed');
}
export function trackPWAInstallDismissed(): void {
trackEvent('info', 'pwa', 'pwa_install_dismissed');
}