import { BaseApiClient } from '../base/BaseApiClient'; import { RecordPageViewOutputDTO } from '../../types/generated/RecordPageViewOutputDTO'; import { RecordEngagementOutputDTO } from '../../types/generated/RecordEngagementOutputDTO'; // TODO: Move these types to apps/website/lib/types/generated when available type RecordPageViewInputDto = { path: string; userId?: string }; type RecordEngagementInputDto = { eventType: string; userId?: string; metadata?: Record }; // TODO: Move these types to apps/website/lib/types/generated when available type AnalyticsDashboardDto = { totalUsers: number; activeUsers: number; totalRaces: number; totalLeagues: number; }; type AnalyticsMetricsDto = { pageViews: number; uniqueVisitors: number; averageSessionDuration: number; bounceRate: number; }; /** * Analytics API Client * * Handles all analytics-related API operations. */ export class AnalyticsApiClient extends BaseApiClient { /** Record a page view */ recordPageView(input: RecordPageViewInputDto): Promise { return this.post('/analytics/page-view', input); } /** Record an engagement event */ recordEngagement(input: RecordEngagementInputDto): Promise { return this.post('/analytics/engagement', input); } /** Get analytics dashboard data */ getDashboardData(): Promise { return this.get('/analytics/dashboard'); } /** Get analytics metrics */ getAnalyticsMetrics(): Promise { return this.get('/analytics/metrics'); } }