2026-02-21 09:53:31 -05:00
|
|
|
import { apiClient } from './apiClient'
|
|
|
|
|
|
|
|
|
|
export interface AnalyticsEvent {
|
2026-02-22 15:31:02 -05:00
|
|
|
event_name: 'app_open' | 'screen_view' | 'route_selected' | 'stop_selected' | 'schedule_viewed' | 'reminder_created' | 'promo_view' | 'promo_click' | 'taxi_view' | 'taxi_click' | 'shuttle_view' | 'shuttle_contact' | 'business_view' | 'business_contact' | 'login' | 'sign_up'
|
2026-02-21 09:53:31 -05:00
|
|
|
screen_name?: string
|
|
|
|
|
item_id?: string
|
|
|
|
|
properties?: Record<string, any>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const analyticsService = {
|
|
|
|
|
logEvent(event: AnalyticsEvent) {
|
|
|
|
|
// Log asynchronously without awaiting to avoid blocking UI
|
|
|
|
|
apiClient.post('/api/analytics/event', event).catch(error => {
|
|
|
|
|
console.warn('Analytics capture failed:', error)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getStats() {
|
|
|
|
|
const response = await apiClient.get('/api/analytics/dashboard/stats')
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
}
|