()
| 43 | } |
| 44 | |
| 45 | export function useTrackEvent() { |
| 46 | return { |
| 47 | // Session events |
| 48 | sessionCreated: (model: string, source?: string) => { |
| 49 | const event = eventBuilders.session({ model, source }); |
| 50 | analytics.track(event.event, event.properties); |
| 51 | }, |
| 52 | |
| 53 | sessionCompleted: () => { |
| 54 | analytics.track(ANALYTICS_EVENTS.SESSION_COMPLETED); |
| 55 | }, |
| 56 | |
| 57 | sessionResumed: (checkpointId: string) => { |
| 58 | const event = eventBuilders.session({ resumed: true, checkpoint_id: checkpointId }); |
| 59 | analytics.track(ANALYTICS_EVENTS.SESSION_RESUMED, event.properties); |
| 60 | }, |
| 61 | |
| 62 | // Feature usage |
| 63 | featureUsed: (feature: string, subfeature?: string, metadata?: Record<string, any>) => { |
| 64 | const event = eventBuilders.feature(feature, subfeature, metadata); |
| 65 | analytics.track(event.event, event.properties); |
| 66 | }, |
| 67 | |
| 68 | // Model selection |
| 69 | modelSelected: (newModel: string, previousModel?: string, source?: string) => { |
| 70 | const event = eventBuilders.model(newModel, previousModel, source); |
| 71 | analytics.track(event.event, event.properties); |
| 72 | }, |
| 73 | |
| 74 | // Tab events |
| 75 | tabCreated: (tabType: string) => { |
| 76 | analytics.track(ANALYTICS_EVENTS.TAB_CREATED, { tab_type: tabType }); |
| 77 | }, |
| 78 | |
| 79 | tabClosed: (tabType: string) => { |
| 80 | analytics.track(ANALYTICS_EVENTS.TAB_CLOSED, { tab_type: tabType }); |
| 81 | }, |
| 82 | |
| 83 | // File operations |
| 84 | fileOpened: (fileType: string) => { |
| 85 | analytics.track(ANALYTICS_EVENTS.FILE_OPENED, { file_type: fileType }); |
| 86 | }, |
| 87 | |
| 88 | fileEdited: (fileType: string) => { |
| 89 | analytics.track(ANALYTICS_EVENTS.FILE_EDITED, { file_type: fileType }); |
| 90 | }, |
| 91 | |
| 92 | fileSaved: (fileType: string) => { |
| 93 | analytics.track(ANALYTICS_EVENTS.FILE_SAVED, { file_type: fileType }); |
| 94 | }, |
| 95 | |
| 96 | // Agent execution |
| 97 | agentExecuted: (agentType: string, success: boolean, agentName?: string, durationMs?: number) => { |
| 98 | const event = eventBuilders.agent(agentType, success, agentName, durationMs); |
| 99 | analytics.track(event.event, event.properties); |
| 100 | }, |
| 101 | |
| 102 | // MCP events |
no test coverage detected