Initial commit: SIBU 2.0 MISSION
This commit is contained in:
22
frontend/src/services/analyticsService.ts
Normal file
22
frontend/src/services/analyticsService.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { apiClient } from './apiClient'
|
||||
|
||||
export interface AnalyticsEvent {
|
||||
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'
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user