@od-oneapp/analytics 2026.1.1301

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +509 -0
  2. package/dist/ai-YMnynb-t.mjs +3347 -0
  3. package/dist/ai-YMnynb-t.mjs.map +1 -0
  4. package/dist/chunk-DQk6qfdC.mjs +18 -0
  5. package/dist/client-CTzJVFU5.mjs +9 -0
  6. package/dist/client-CTzJVFU5.mjs.map +1 -0
  7. package/dist/client-CcFTauAh.mjs +54 -0
  8. package/dist/client-CcFTauAh.mjs.map +1 -0
  9. package/dist/client-CeOLjbac.mjs +281 -0
  10. package/dist/client-CeOLjbac.mjs.map +1 -0
  11. package/dist/client-D339NFJS.mjs +267 -0
  12. package/dist/client-D339NFJS.mjs.map +1 -0
  13. package/dist/client-next.d.mts +62 -0
  14. package/dist/client-next.d.mts.map +1 -0
  15. package/dist/client-next.mjs +525 -0
  16. package/dist/client-next.mjs.map +1 -0
  17. package/dist/client.d.mts +30 -0
  18. package/dist/client.d.mts.map +1 -0
  19. package/dist/client.mjs +186 -0
  20. package/dist/client.mjs.map +1 -0
  21. package/dist/config-DPS6bSYo.d.mts +34 -0
  22. package/dist/config-DPS6bSYo.d.mts.map +1 -0
  23. package/dist/config-P6P5adJg.mjs +287 -0
  24. package/dist/config-P6P5adJg.mjs.map +1 -0
  25. package/dist/console-8bND3mMU.mjs +128 -0
  26. package/dist/console-8bND3mMU.mjs.map +1 -0
  27. package/dist/ecommerce-Cgu4wlux.mjs +993 -0
  28. package/dist/ecommerce-Cgu4wlux.mjs.map +1 -0
  29. package/dist/emitters-6-nKo8i-.mjs +208 -0
  30. package/dist/emitters-6-nKo8i-.mjs.map +1 -0
  31. package/dist/emitters-DldkVSPp.d.mts +12 -0
  32. package/dist/emitters-DldkVSPp.d.mts.map +1 -0
  33. package/dist/index-BfNWgfa5.d.mts +1494 -0
  34. package/dist/index-BfNWgfa5.d.mts.map +1 -0
  35. package/dist/index-BkIWe--N.d.mts +953 -0
  36. package/dist/index-BkIWe--N.d.mts.map +1 -0
  37. package/dist/index-jPzXRn52.d.mts +184 -0
  38. package/dist/index-jPzXRn52.d.mts.map +1 -0
  39. package/dist/manager-DvRRjza6.d.mts +76 -0
  40. package/dist/manager-DvRRjza6.d.mts.map +1 -0
  41. package/dist/posthog-bootstrap-CYfIy_WS.mjs +1769 -0
  42. package/dist/posthog-bootstrap-CYfIy_WS.mjs.map +1 -0
  43. package/dist/posthog-bootstrap-DWxFrxlt.d.mts +81 -0
  44. package/dist/posthog-bootstrap-DWxFrxlt.d.mts.map +1 -0
  45. package/dist/providers-http-client.d.mts +37 -0
  46. package/dist/providers-http-client.d.mts.map +1 -0
  47. package/dist/providers-http-client.mjs +320 -0
  48. package/dist/providers-http-client.mjs.map +1 -0
  49. package/dist/providers-http-server.d.mts +31 -0
  50. package/dist/providers-http-server.d.mts.map +1 -0
  51. package/dist/providers-http-server.mjs +297 -0
  52. package/dist/providers-http-server.mjs.map +1 -0
  53. package/dist/providers-http.d.mts +46 -0
  54. package/dist/providers-http.d.mts.map +1 -0
  55. package/dist/providers-http.mjs +4 -0
  56. package/dist/server-edge.d.mts +9 -0
  57. package/dist/server-edge.d.mts.map +1 -0
  58. package/dist/server-edge.mjs +373 -0
  59. package/dist/server-edge.mjs.map +1 -0
  60. package/dist/server-next.d.mts +67 -0
  61. package/dist/server-next.d.mts.map +1 -0
  62. package/dist/server-next.mjs +193 -0
  63. package/dist/server-next.mjs.map +1 -0
  64. package/dist/server.d.mts +10 -0
  65. package/dist/server.mjs +7 -0
  66. package/dist/service-cYtBBL8x.mjs +945 -0
  67. package/dist/service-cYtBBL8x.mjs.map +1 -0
  68. package/dist/shared.d.mts +16 -0
  69. package/dist/shared.d.mts.map +1 -0
  70. package/dist/shared.mjs +93 -0
  71. package/dist/shared.mjs.map +1 -0
  72. package/dist/types-BxBnNQ0V.d.mts +354 -0
  73. package/dist/types-BxBnNQ0V.d.mts.map +1 -0
  74. package/dist/types-CBvxUEaF.d.mts +216 -0
  75. package/dist/types-CBvxUEaF.d.mts.map +1 -0
  76. package/dist/types.d.mts +4 -0
  77. package/dist/types.mjs +0 -0
  78. package/dist/vercel-types-lwakUfoI.d.mts +102 -0
  79. package/dist/vercel-types-lwakUfoI.d.mts.map +1 -0
  80. package/package.json +129 -0
  81. package/src/client/index.ts +164 -0
  82. package/src/client/manager.ts +71 -0
  83. package/src/client/next/components.tsx +270 -0
  84. package/src/client/next/hooks.ts +217 -0
  85. package/src/client/next/manager.ts +141 -0
  86. package/src/client/next.ts +144 -0
  87. package/src/client-next.ts +101 -0
  88. package/src/client.ts +89 -0
  89. package/src/examples/ai-sdk-patterns.ts +583 -0
  90. package/src/examples/emitter-patterns.ts +476 -0
  91. package/src/examples/nextjs-emitter-patterns.tsx +403 -0
  92. package/src/next/app-router.tsx +564 -0
  93. package/src/next/client.ts +419 -0
  94. package/src/next/index.ts +84 -0
  95. package/src/next/middleware.ts +429 -0
  96. package/src/next/rsc.tsx +300 -0
  97. package/src/next/server.ts +253 -0
  98. package/src/next/types.d.ts +220 -0
  99. package/src/providers/base-provider.ts +419 -0
  100. package/src/providers/console/client.ts +10 -0
  101. package/src/providers/console/index.ts +152 -0
  102. package/src/providers/console/server.ts +6 -0
  103. package/src/providers/console/types.ts +15 -0
  104. package/src/providers/http/client.ts +464 -0
  105. package/src/providers/http/index.ts +30 -0
  106. package/src/providers/http/server.ts +396 -0
  107. package/src/providers/http/types.ts +135 -0
  108. package/src/providers/posthog/client.ts +518 -0
  109. package/src/providers/posthog/index.ts +11 -0
  110. package/src/providers/posthog/server.ts +329 -0
  111. package/src/providers/posthog/types.ts +104 -0
  112. package/src/providers/segment/client.ts +113 -0
  113. package/src/providers/segment/index.ts +11 -0
  114. package/src/providers/segment/server.ts +115 -0
  115. package/src/providers/segment/types.ts +51 -0
  116. package/src/providers/vercel/client.ts +102 -0
  117. package/src/providers/vercel/index.ts +11 -0
  118. package/src/providers/vercel/server.ts +89 -0
  119. package/src/providers/vercel/types.ts +27 -0
  120. package/src/server/index.ts +103 -0
  121. package/src/server/manager.ts +62 -0
  122. package/src/server/next.ts +210 -0
  123. package/src/server-edge.ts +442 -0
  124. package/src/server-next.ts +39 -0
  125. package/src/server.ts +106 -0
  126. package/src/shared/emitters/ai/README.md +981 -0
  127. package/src/shared/emitters/ai/events/agent.ts +130 -0
  128. package/src/shared/emitters/ai/events/artifacts.ts +167 -0
  129. package/src/shared/emitters/ai/events/chat.ts +126 -0
  130. package/src/shared/emitters/ai/events/chatbot-ecommerce.ts +133 -0
  131. package/src/shared/emitters/ai/events/completion.ts +103 -0
  132. package/src/shared/emitters/ai/events/content-generation.ts +347 -0
  133. package/src/shared/emitters/ai/events/conversation.ts +332 -0
  134. package/src/shared/emitters/ai/events/product-features.ts +1402 -0
  135. package/src/shared/emitters/ai/events/streaming.ts +114 -0
  136. package/src/shared/emitters/ai/events/tool.ts +93 -0
  137. package/src/shared/emitters/ai/index.ts +69 -0
  138. package/src/shared/emitters/ai/track-ai-sdk.ts +74 -0
  139. package/src/shared/emitters/ai/track-ai.ts +50 -0
  140. package/src/shared/emitters/ai/types.ts +1041 -0
  141. package/src/shared/emitters/ai/utils.ts +468 -0
  142. package/src/shared/emitters/ecommerce/events/cart-checkout.ts +106 -0
  143. package/src/shared/emitters/ecommerce/events/coupon.ts +49 -0
  144. package/src/shared/emitters/ecommerce/events/engagement.ts +61 -0
  145. package/src/shared/emitters/ecommerce/events/marketplace.ts +119 -0
  146. package/src/shared/emitters/ecommerce/events/order.ts +199 -0
  147. package/src/shared/emitters/ecommerce/events/product.ts +205 -0
  148. package/src/shared/emitters/ecommerce/events/registry.ts +123 -0
  149. package/src/shared/emitters/ecommerce/events/wishlist-sharing.ts +140 -0
  150. package/src/shared/emitters/ecommerce/index.ts +46 -0
  151. package/src/shared/emitters/ecommerce/track-ecommerce.ts +53 -0
  152. package/src/shared/emitters/ecommerce/types.ts +314 -0
  153. package/src/shared/emitters/ecommerce/utils.ts +216 -0
  154. package/src/shared/emitters/emitter-types.ts +974 -0
  155. package/src/shared/emitters/emitters.ts +292 -0
  156. package/src/shared/emitters/helpers.ts +419 -0
  157. package/src/shared/emitters/index.ts +66 -0
  158. package/src/shared/index.ts +142 -0
  159. package/src/shared/ingestion/index.ts +66 -0
  160. package/src/shared/ingestion/schemas.ts +386 -0
  161. package/src/shared/ingestion/service.ts +628 -0
  162. package/src/shared/node22-features.ts +848 -0
  163. package/src/shared/providers/console-provider.ts +160 -0
  164. package/src/shared/types/base-types.ts +54 -0
  165. package/src/shared/types/console-types.ts +19 -0
  166. package/src/shared/types/posthog-types.ts +131 -0
  167. package/src/shared/types/segment-types.ts +15 -0
  168. package/src/shared/types/types.ts +397 -0
  169. package/src/shared/types/vercel-types.ts +19 -0
  170. package/src/shared/utils/config-client.ts +19 -0
  171. package/src/shared/utils/config.ts +250 -0
  172. package/src/shared/utils/emitter-adapter.ts +212 -0
  173. package/src/shared/utils/manager.test.ts +36 -0
  174. package/src/shared/utils/manager.ts +1322 -0
  175. package/src/shared/utils/posthog-bootstrap.ts +136 -0
  176. package/src/shared/utils/posthog-client-utils.ts +48 -0
  177. package/src/shared/utils/posthog-next-utils.ts +282 -0
  178. package/src/shared/utils/posthog-server-utils.ts +210 -0
  179. package/src/shared/utils/rate-limit.ts +289 -0
  180. package/src/shared/utils/security.ts +545 -0
  181. package/src/shared/utils/validation-client.ts +161 -0
  182. package/src/shared/utils/validation.ts +399 -0
  183. package/src/shared.ts +155 -0
  184. package/src/types/index.ts +62 -0
@@ -0,0 +1,1041 @@
1
+ /**
2
+ * @fileoverview Platform-standard AI product event types
3
+ * Platform-standard AI product event types
4
+ *
5
+ * Comprehensive tracking for AI assistant/copilot products like ChatGPT, Claude, Copilot.
6
+ * Tracks product features, user interactions, and system operations - NOT use-case specific.
7
+ *
8
+ * Completely separate from e-commerce tracking.
9
+ */
10
+
11
+ // =============================================================================
12
+ // BASE PROPERTIES
13
+ // =============================================================================
14
+
15
+ export interface BaseAIProperties {
16
+ agent_id?: string | undefined;
17
+ agent_name?: string | undefined;
18
+ conversation_id?: string | undefined;
19
+ message_id?: string | undefined;
20
+ model_id: string;
21
+ model_provider?:
22
+ | 'anthropic'
23
+ | 'openai'
24
+ | 'google'
25
+ | 'perplexity'
26
+ | 'cohere'
27
+ | 'mistral'
28
+ | 'other'
29
+ | undefined;
30
+ operation_id?: string | undefined;
31
+ session_id?: string | undefined;
32
+ user_id?: string | undefined;
33
+ workspace_id?: string | undefined;
34
+ }
35
+
36
+ export interface TokenUsageProperties {
37
+ cost?: number;
38
+ cost_currency?: string;
39
+ input_tokens?: number;
40
+ output_tokens?: number;
41
+ total_tokens?: number;
42
+ }
43
+
44
+ export interface ModelConfigProperties {
45
+ frequency_penalty?: number;
46
+ max_tokens?: number;
47
+ max_output_tokens?: number;
48
+ presence_penalty?: number;
49
+ seed?: number;
50
+ stop_sequences?: string[];
51
+ temperature?: number;
52
+ top_p?: number;
53
+ }
54
+
55
+ // =============================================================================
56
+ // CONVERSATION & MESSAGING
57
+ // =============================================================================
58
+
59
+ export interface ConversationProperties extends BaseAIProperties {
60
+ conversation_title?: string;
61
+ folder_id?: string;
62
+ is_shared?: boolean;
63
+ parent_conversation_id?: string; // For branching
64
+ total_messages?: number;
65
+ conversation_type?: string;
66
+ last_active_timestamp?: number;
67
+ end_reason?: string;
68
+ [key: string]: any;
69
+ }
70
+
71
+ export interface MessageProperties extends BaseAIProperties, TokenUsageProperties {
72
+ content_length?: number;
73
+ has_attachments?: boolean;
74
+ has_code?: boolean;
75
+ has_images?: boolean;
76
+ is_edited?: boolean;
77
+ is_regenerated?: boolean;
78
+ message_index?: number;
79
+ message_role: 'user' | 'assistant' | 'system' | 'tool';
80
+ parent_message_id?: string; // For branching
81
+ response_time_ms?: number;
82
+ finish_reason?: string;
83
+ is_streaming?: boolean;
84
+ message_length?: number;
85
+ edit_type?: string;
86
+ deleted_by?: string;
87
+ [key: string]: any;
88
+ }
89
+
90
+ export interface RegenerationProperties extends BaseAIProperties {
91
+ attempt_number?: number;
92
+ original_message_id: string;
93
+ reason?: 'user-requested' | 'error-recovery' | 'quality-improvement';
94
+ temperature_adjusted?: boolean;
95
+ [key: string]: any;
96
+ }
97
+
98
+ export interface MessageEditProperties extends BaseAIProperties {
99
+ edit_type: 'user-message' | 'assistant-message';
100
+ edited_message_id: string;
101
+ new_length?: number;
102
+ original_length?: number;
103
+ [key: string]: any;
104
+ }
105
+
106
+ export interface BranchProperties extends BaseAIProperties {
107
+ branch_point_message_id: string;
108
+ new_conversation_id: string;
109
+ original_conversation_id: string;
110
+ reason?: 'explore-alternative' | 'correct-error' | 'user-initiated';
111
+ merge_strategy?: string;
112
+ [key: string]: any;
113
+ }
114
+
115
+ export interface StopGenerationProperties extends BaseAIProperties {
116
+ partial_length?: number;
117
+ stop_reason?: 'user-interrupted' | 'user-stopped' | 'timeout' | 'error';
118
+ tokens_used_at_stop?: number;
119
+ [key: string]: any;
120
+ }
121
+
122
+ // =============================================================================
123
+ // CONTENT GENERATION
124
+ // =============================================================================
125
+
126
+ export interface TextGenerationProperties extends BaseAIProperties, TokenUsageProperties {
127
+ content_type: 'general' | 'creative' | 'technical' | 'summary' | 'translation';
128
+ finish_reason?: 'stop' | 'length' | 'content_filter';
129
+ generation_time_ms?: number;
130
+ output_length?: number;
131
+ prompt_length?: number;
132
+ }
133
+
134
+ export interface CodeGenerationProperties extends BaseAIProperties, TokenUsageProperties {
135
+ code_length?: number;
136
+ has_explanation?: boolean;
137
+ has_tests?: boolean;
138
+ language?: string;
139
+ source?: string;
140
+ task_type?: 'generate' | 'edit' | 'debug' | 'explain' | 'refactor' | 'translate';
141
+ code_type?: string;
142
+ explanation_length?: number;
143
+ explanation_type?: string;
144
+ issues_found?: number;
145
+ refactor_type?: string;
146
+ source_language?: string;
147
+ [key: string]: any;
148
+ }
149
+
150
+ export interface ImageGenerationProperties extends BaseAIProperties {
151
+ generation_time_ms?: number;
152
+ height?: number;
153
+ image_format?: 'png' | 'jpg' | 'webp';
154
+ model?: string; // DALL-E, Midjourney, Stable Diffusion
155
+ prompt_length?: number;
156
+ quality?: 'standard' | 'hd';
157
+ revisions?: number;
158
+ style?: string;
159
+ width?: number;
160
+ image_type?: string;
161
+ [key: string]: any;
162
+ }
163
+
164
+ export interface SummaryProperties extends BaseAIProperties, TokenUsageProperties {
165
+ input_length?: number;
166
+ output_length?: number;
167
+ source_type?: 'conversation' | 'document' | 'webpage' | 'code';
168
+ summary_type?: 'brief' | 'detailed' | 'key-points' | 'tldr';
169
+ source_length?: number;
170
+ [key: string]: any;
171
+ }
172
+
173
+ export interface TranslationProperties extends BaseAIProperties, TokenUsageProperties {
174
+ source_language?: string;
175
+ target_language?: string;
176
+ text_length?: number;
177
+ translation_quality?: 'literal' | 'natural' | 'formal';
178
+ [key: string]: any;
179
+ }
180
+
181
+ export interface ContentGenerationProperties extends BaseAIProperties, TokenUsageProperties {
182
+ content_type?: string;
183
+ generation_time_ms?: number;
184
+ output_length?: number;
185
+ prompt_length?: number;
186
+ content_length?: number;
187
+ content_format?: string;
188
+ completion_type?: string;
189
+ rewrite_style?: string;
190
+ email_type?: string;
191
+ document_type?: string;
192
+ section_count?: number;
193
+ source_language?: string;
194
+ [key: string]: any;
195
+ }
196
+
197
+ // =============================================================================
198
+ // FILES & ATTACHMENTS
199
+ // =============================================================================
200
+
201
+ export interface FileUploadProperties extends BaseAIProperties {
202
+ file_size_bytes?: number;
203
+ file_type: string;
204
+ upload_duration_ms?: number;
205
+ [key: string]: any;
206
+ }
207
+
208
+ export interface FileAnalysisProperties extends BaseAIProperties, TokenUsageProperties {
209
+ analysis_type: 'read' | 'summarize' | 'extract' | 'question-answer';
210
+ file_id: string;
211
+ file_type: string;
212
+ processing_time_ms?: number;
213
+ [key: string]: any;
214
+ }
215
+
216
+ export interface ImageAnalysisProperties extends BaseAIProperties, TokenUsageProperties {
217
+ analysis_type: 'describe' | 'ocr' | 'question-answer' | 'object-detection';
218
+ image_id: string;
219
+ image_size_bytes?: number;
220
+ [key: string]: any;
221
+ }
222
+
223
+ // =============================================================================
224
+ // SEARCH, BROWSE & CITATIONS
225
+ // =============================================================================
226
+
227
+ export interface WebSearchProperties extends BaseAIProperties {
228
+ query: string;
229
+ results_count?: number;
230
+ search_duration_ms?: number;
231
+ search_provider?: string;
232
+ [key: string]: any;
233
+ }
234
+
235
+ export interface WebBrowseProperties extends BaseAIProperties {
236
+ duration_ms?: number;
237
+ page_content_length?: number;
238
+ url: string;
239
+ [key: string]: any;
240
+ }
241
+
242
+ export interface CitationProperties extends BaseAIProperties {
243
+ citation_count?: number;
244
+ citation_format?: 'inline' | 'footnote' | 'reference-list';
245
+ message_id: string;
246
+ sources?: string[];
247
+ [key: string]: any;
248
+ }
249
+
250
+ // =============================================================================
251
+ // TOOLS & FUNCTIONS
252
+ // =============================================================================
253
+
254
+ export interface ToolCallProperties extends BaseAIProperties {
255
+ error_message?: string;
256
+ execution_time_ms?: number;
257
+ input_params?: Record<string, any>;
258
+ input_size?: number;
259
+ output_size?: number;
260
+ result_status: 'success' | 'error' | 'timeout';
261
+ tool_name: string;
262
+ tool_type: 'built-in' | 'plugin' | 'custom' | 'api';
263
+ [key: string]: any;
264
+ }
265
+
266
+ export interface PluginProperties extends BaseAIProperties {
267
+ plugin_id: string;
268
+ plugin_name: string;
269
+ plugin_version?: string;
270
+ [key: string]: any;
271
+ }
272
+
273
+ export interface APICallProperties extends BaseAIProperties {
274
+ api_endpoint: string;
275
+ api_method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
276
+ response_time_ms?: number;
277
+ status_code?: number;
278
+ [key: string]: any;
279
+ }
280
+
281
+ // =============================================================================
282
+ // CONTEXT & MEMORY
283
+ // =============================================================================
284
+
285
+ export interface ContextProperties extends BaseAIProperties {
286
+ context_length_tokens?: number;
287
+ context_source?: 'history' | 'memory' | 'custom-instructions' | 'system';
288
+ context_type: 'added' | 'updated' | 'pruned' | 'cleared';
289
+ tokens_saved?: number;
290
+ [key: string]: any;
291
+ }
292
+
293
+ export interface MemoryProperties extends BaseAIProperties {
294
+ memory_id?: string;
295
+ memory_recalled?: boolean;
296
+ memory_type: 'stored' | 'retrieved' | 'updated' | 'cleared';
297
+ relevance_score?: number;
298
+ [key: string]: any;
299
+ }
300
+
301
+ export interface CustomInstructionsProperties extends BaseAIProperties {
302
+ instructions_length?: number;
303
+ instructions_type: 'created' | 'updated' | 'cleared';
304
+ template_used?: boolean;
305
+ [key: string]: any;
306
+ }
307
+
308
+ // =============================================================================
309
+ // USER INTERACTIONS & PREFERENCES
310
+ // =============================================================================
311
+
312
+ export interface ModelSelectionProperties extends BaseAIProperties {
313
+ previous_model_id?: string;
314
+ reason?: 'user-preference' | 'feature-requirement' | 'cost-optimization';
315
+ selected_model_id: string;
316
+ [key: string]: any;
317
+ }
318
+
319
+ export interface ParameterAdjustmentProperties extends BaseAIProperties {
320
+ new_value: number | string;
321
+ parameter_name: 'temperature' | 'max_tokens' | 'top_p' | 'frequency_penalty';
322
+ previous_value?: number | string;
323
+ [key: string]: any;
324
+ }
325
+
326
+ export interface VoiceProperties extends BaseAIProperties {
327
+ audio_duration_ms?: number;
328
+ language?: string;
329
+ voice_type: 'input' | 'output';
330
+ [key: string]: any;
331
+ }
332
+
333
+ export interface StreamingProperties extends BaseAIProperties {
334
+ chunk_count?: number;
335
+ chunks_per_second?: number;
336
+ first_chunk_latency_ms?: number;
337
+ stream_duration_ms?: number;
338
+ stream_type?: 'text' | 'audio' | 'video' | 'image';
339
+ time_to_first_chunk_ms?: number;
340
+ was_stopped?: boolean;
341
+ chunk_index?: number;
342
+ total_bytes?: number;
343
+ [key: string]: any;
344
+ }
345
+
346
+ export interface CopyExportProperties extends BaseAIProperties {
347
+ action: 'copy-message' | 'copy-code' | 'export-conversation' | 'download-file';
348
+ content_length?: number;
349
+ export_format?: 'markdown' | 'json' | 'pdf' | 'txt';
350
+ }
351
+
352
+ // =============================================================================
353
+ // WORKSPACE & ORGANIZATION
354
+ // =============================================================================
355
+
356
+ export interface ConversationManagementProperties extends BaseAIProperties {
357
+ action: 'save' | 'rename' | 'delete' | 'archive' | 'pin' | 'move' | 'duplicate';
358
+ new_folder_id?: string;
359
+ new_title?: string;
360
+ }
361
+
362
+ export interface FolderProperties extends BaseAIProperties {
363
+ action: 'create' | 'rename' | 'delete' | 'move';
364
+ conversation_count?: number;
365
+ folder_id: string;
366
+ folder_name?: string;
367
+ parent_folder_id?: string;
368
+ }
369
+
370
+ export interface SearchProperties extends BaseAIProperties {
371
+ query: string;
372
+ results_count?: number;
373
+ search_scope: 'conversations' | 'messages' | 'all';
374
+ search_time_ms?: number;
375
+ }
376
+
377
+ export interface TemplateProperties extends BaseAIProperties {
378
+ action: 'create' | 'use' | 'edit' | 'delete';
379
+ category?: string;
380
+ template_id?: string;
381
+ template_name?: string;
382
+ }
383
+
384
+ // =============================================================================
385
+ // COLLABORATION & SHARING
386
+ // =============================================================================
387
+
388
+ export interface ShareProperties extends BaseAIProperties {
389
+ expiration_time?: string;
390
+ share_id?: string;
391
+ share_scope: 'public' | 'team' | 'private-link';
392
+ share_type: 'conversation' | 'message' | 'artifact';
393
+ }
394
+
395
+ export interface WorkspaceProperties extends BaseAIProperties {
396
+ action: 'create' | 'update' | 'delete' | 'invite';
397
+ member_count?: number;
398
+ workspace_name?: string;
399
+ }
400
+
401
+ export interface TeamProperties extends BaseAIProperties {
402
+ action: 'invite' | 'remove' | 'update-role';
403
+ member_email?: string;
404
+ member_role?: 'admin' | 'member' | 'viewer';
405
+ team_id: string;
406
+ }
407
+
408
+ export interface CommentProperties extends BaseAIProperties {
409
+ comment_id?: string;
410
+ comment_length?: number;
411
+ message_id: string;
412
+ parent_comment_id?: string;
413
+ }
414
+
415
+ // =============================================================================
416
+ // ARTIFACTS & CANVAS (Claude-style features)
417
+ // =============================================================================
418
+
419
+ export interface ArtifactProperties extends BaseAIProperties {
420
+ action: 'create' | 'edit' | 'publish' | 'delete' | 'fork' | 'execute';
421
+ artifact_id?: string;
422
+ artifact_type: 'code' | 'document' | 'visualization' | 'react-component' | 'svg';
423
+ error_message?: string;
424
+ execution_status?: 'success' | 'failed' | 'pending' | 'error';
425
+ execution_time_ms?: number;
426
+ language?: string;
427
+ version?: number;
428
+ content_length?: number;
429
+ changes_description?: string;
430
+ new_artifact_id?: string;
431
+ [key: string]: any;
432
+ }
433
+
434
+ export interface CanvasProperties extends BaseAIProperties {
435
+ action: 'open' | 'edit' | 'close' | 'save' | 'execute';
436
+ canvas_id?: string;
437
+ content_type?: 'code' | 'markdown' | 'mermaid' | 'html';
438
+ execution_result?: 'success' | 'error';
439
+ canvas_type?: string;
440
+ artifact_id?: string;
441
+ preview_enabled?: boolean;
442
+ [key: string]: any;
443
+ }
444
+
445
+ // =============================================================================
446
+ // FEEDBACK & QUALITY
447
+ // =============================================================================
448
+
449
+ export interface FeedbackProperties extends BaseAIProperties {
450
+ feedback_category?: 'accuracy' | 'helpfulness' | 'safety' | 'quality' | 'other';
451
+ feedback_text?: string;
452
+ feedback_type: 'thumbs-up' | 'thumbs-down' | 'rating' | 'detailed';
453
+ message_id: string;
454
+ rating?: number;
455
+ [key: string]: any;
456
+ }
457
+
458
+ export interface IssueReportProperties extends BaseAIProperties {
459
+ issue_category: 'bug' | 'incorrect-output' | 'inappropriate-content' | 'other';
460
+ issue_description?: string;
461
+ message_id?: string;
462
+ severity?: 'low' | 'medium' | 'high';
463
+ [key: string]: any;
464
+ }
465
+
466
+ export interface SafetyProperties extends BaseAIProperties {
467
+ action_taken?: 'blocked' | 'warned' | 'flagged';
468
+ category?: 'harmful' | 'inappropriate' | 'policy-violation';
469
+ message_id?: string;
470
+ safety_score?: number;
471
+ [key: string]: any;
472
+ }
473
+
474
+ // =============================================================================
475
+ // SYSTEM & PERFORMANCE
476
+ // =============================================================================
477
+
478
+ export interface RateLimitProperties extends BaseAIProperties {
479
+ limit_type: 'requests' | 'tokens' | 'cost';
480
+ reset_time_seconds?: number;
481
+ tier?: string;
482
+ [key: string]: any;
483
+ }
484
+
485
+ export interface ErrorProperties extends BaseAIProperties {
486
+ error_code?: string;
487
+ error_message: string;
488
+ error_type:
489
+ | 'api'
490
+ | 'timeout'
491
+ | 'network'
492
+ | 'validation'
493
+ | 'content-filter'
494
+ | 'rate-limit'
495
+ | 'unknown';
496
+ operation: string;
497
+ retry_attempted?: boolean;
498
+ [key: string]: any;
499
+ }
500
+
501
+ export interface LatencyProperties extends BaseAIProperties {
502
+ latency_ms: number;
503
+ latency_type: 'first-token' | 'total' | 'network' | 'processing';
504
+ operation: string;
505
+ [key: string]: any;
506
+ }
507
+
508
+ export interface CostTrackingProperties extends BaseAIProperties, TokenUsageProperties {
509
+ cost_breakdown?: {
510
+ input_cost?: number;
511
+ output_cost?: number;
512
+ tool_cost?: number;
513
+ };
514
+ cost_per_request?: number;
515
+ pricing_tier?: string;
516
+ [key: string]: any;
517
+ }
518
+
519
+ // =============================================================================
520
+ // ADDITIONAL PROPERTY GROUPS (for product-features.ts)
521
+ // =============================================================================
522
+
523
+ export interface CollaborationProperties extends BaseAIProperties {
524
+ member_id?: string;
525
+ member_role?: string;
526
+ permission_level?: string;
527
+ shared_with_count?: number;
528
+ share_type?: 'public' | 'team' | 'specific-users';
529
+ [key: string]: any;
530
+ }
531
+
532
+ export interface FileProperties extends BaseAIProperties {
533
+ batch_size?: number;
534
+ extraction_method?: string;
535
+ file_count?: number;
536
+ file_id?: string;
537
+ file_name?: string;
538
+ file_size?: number;
539
+ file_type?: string;
540
+ processing_time_ms?: number;
541
+ file_size_bytes?: number;
542
+ total_size_bytes?: number;
543
+ extracted_text_length?: number;
544
+ processing_status?: string;
545
+ reference_context?: string;
546
+ [key: string]: any;
547
+ }
548
+
549
+ export interface PerformanceProperties extends BaseAIProperties {
550
+ duration_ms?: number;
551
+ latency_ms?: number;
552
+ metric_name?: string;
553
+ metric_value?: number;
554
+ [key: string]: any;
555
+ }
556
+
557
+ export interface SystemProperties extends BaseAIProperties {
558
+ error_code?: string;
559
+ error_message?: string;
560
+ setting_name?: string;
561
+ setting_value?: string;
562
+ system_event?: string;
563
+ [key: string]: any;
564
+ }
565
+
566
+ export interface ToolProperties extends BaseAIProperties {
567
+ execution_time_ms?: number;
568
+ input_data?: Record<string, any>;
569
+ output_data?: Record<string, any>;
570
+ tool_id?: string;
571
+ tool_name?: string;
572
+ [key: string]: any;
573
+ }
574
+
575
+ export interface UserInteractionProperties extends BaseAIProperties {
576
+ action?: string;
577
+ content_length?: number;
578
+ content_type?: string;
579
+ interaction_type?: string;
580
+ target_id?: string;
581
+ content_id?: string;
582
+ suggestion_type?: string;
583
+ [key: string]: any;
584
+ }
585
+
586
+ // =============================================================================
587
+ // STANDARD AI EVENT NAMES (100+ EVENTS)
588
+ // =============================================================================
589
+
590
+ export const AI_EVENTS = {
591
+ // ===== CONVERSATION & MESSAGING =====
592
+ BRANCH_CREATED: 'AI Branch Created',
593
+ BRANCH_MERGED: 'AI Branch Merged',
594
+ CONVERSATION_CONTINUED: 'AI Conversation Continued',
595
+ CONVERSATION_DELETED: 'AI Conversation Deleted',
596
+ CONVERSATION_ENDED: 'AI Conversation Ended',
597
+ CONVERSATION_RESUMED: 'AI Conversation Resumed',
598
+ CONVERSATION_STARTED: 'AI Conversation Started',
599
+ MESSAGE_DELETED: 'AI Message Deleted',
600
+ MESSAGE_EDITED: 'AI Message Edited',
601
+ MESSAGE_RECEIVED: 'AI Message Received',
602
+ MESSAGE_REGENERATED: 'AI Message Regenerated',
603
+ MESSAGE_SENT: 'AI Message Sent',
604
+ STOP_GENERATION: 'AI Stop Generation',
605
+ STREAMING_CHUNK_RECEIVED: 'AI Streaming Chunk Received',
606
+
607
+ // ===== CONTENT GENERATION =====
608
+ CODE_DEBUGGED: 'AI Code Debugged',
609
+ CODE_EDITED: 'AI Code Edited',
610
+ CODE_EXECUTED: 'AI Code Executed',
611
+ CODE_EXPLAINED: 'AI Code Explained',
612
+ CODE_GENERATED: 'AI Code Generated',
613
+ CODE_REFACTORED: 'AI Code Refactored',
614
+ CODE_TRANSLATED: 'AI Code Translated',
615
+ COMPLETION_GENERATED: 'AI Completion Generated',
616
+ CONTENT_COPIED: 'AI Content Copied',
617
+ CONTENT_DOWNLOADED: 'AI Content Downloaded',
618
+ CONTENT_REWRITTEN: 'AI Content Rewritten',
619
+ CONTENT_SHARED: 'AI Content Shared',
620
+ DIFF_VIEWED: 'AI Diff Viewed',
621
+ DOCUMENT_CREATED: 'AI Document Created',
622
+ EMAIL_DRAFTED: 'AI Email Drafted',
623
+ IMAGE_EDITED: 'AI Image Edited',
624
+ IMAGE_GENERATED: 'AI Image Generated',
625
+ IMAGE_REVISED: 'AI Image Revised',
626
+ INLINE_EDIT_APPLIED: 'AI Inline Edit Applied',
627
+ OUTLINE_CREATED: 'AI Outline Created',
628
+ REWRITE_GENERATED: 'AI Rewrite Generated',
629
+ SUGGESTION_ACCEPTED: 'AI Suggestion Accepted',
630
+ SUGGESTION_REJECTED: 'AI Suggestion Rejected',
631
+ SUMMARY_GENERATED: 'AI Summary Generated',
632
+ TEXT_GENERATED: 'AI Text Generated',
633
+ TEXT_TRANSLATED: 'AI Text Translated',
634
+ TRANSLATION_GENERATED: 'AI Translation Generated',
635
+
636
+ // ===== FILES & ATTACHMENTS =====
637
+ BATCH_FILES_PROCESSED: 'AI Batch Files Processed',
638
+ FILE_ANALYZED: 'AI File Analyzed',
639
+ FILE_DELETED: 'AI File Deleted',
640
+ FILE_DOWNLOADED: 'AI File Downloaded',
641
+ FILE_PROCESSED: 'AI File Processed',
642
+ FILE_PROCESSING_FAILED: 'AI File Processing Failed',
643
+ FILE_REFERENCED: 'AI File Referenced',
644
+ FILE_UPLOADED: 'AI File Uploaded',
645
+ IMAGE_ANALYZED: 'AI Image Analyzed',
646
+ IMAGE_UPLOADED: 'AI Image Uploaded',
647
+
648
+ // ===== SEARCH, BROWSE & CITATIONS =====
649
+ BROWSE_SESSION_STARTED: 'AI Browse Session Started',
650
+ CITATION_ADDED: 'AI Citation Added',
651
+ CITATION_PROVIDED: 'AI Citation Provided',
652
+ EXTERNAL_SOURCE_ACCESSED: 'AI External Source Accessed',
653
+ PAGE_CONTENT_FETCHED: 'AI Page Content Fetched',
654
+ SEARCH_RESULTS_RANKED: 'AI Search Results Ranked',
655
+ WEB_BROWSED: 'AI Web Browsed',
656
+ WEB_SEARCH_PERFORMED: 'AI Web Search Performed',
657
+ WEB_SEARCHED: 'AI Web Searched',
658
+
659
+ // ===== TOOLS & FUNCTIONS =====
660
+ API_CALLED: 'AI API Called',
661
+ API_REQUEST_MADE: 'AI API Request Made',
662
+ EXTENSION_USED: 'AI Extension Used',
663
+ FUNCTION_EXECUTED: 'AI Function Executed',
664
+ PLUGIN_ACTIVATED: 'AI Plugin Activated',
665
+ PLUGIN_DISABLED: 'AI Plugin Disabled',
666
+ PLUGIN_ENABLED: 'AI Plugin Enabled',
667
+ PLUGIN_USED: 'AI Plugin Used',
668
+ TOOL_CALL_COMPLETED: 'AI Tool Call Completed',
669
+ TOOL_CALL_FAILED: 'AI Tool Call Failed',
670
+ TOOL_CALL_STARTED: 'AI Tool Call Started',
671
+ TOOL_CALLED: 'AI Tool Called',
672
+ TOOL_FAILED: 'AI Tool Failed',
673
+
674
+ // ===== CONTEXT & MEMORY =====
675
+ CONTEXT_CLEARED: 'AI Context Cleared',
676
+ CONTEXT_PRUNED: 'AI Context Pruned',
677
+ CONTEXT_UPDATED: 'AI Context Updated',
678
+ CONTEXT_WINDOW_UPDATED: 'AI Context Window Updated',
679
+ CUSTOM_INSTRUCTIONS_CLEARED: 'AI Custom Instructions Cleared',
680
+ CUSTOM_INSTRUCTIONS_CREATED: 'AI Custom Instructions Created',
681
+ CUSTOM_INSTRUCTIONS_UPDATED: 'AI Custom Instructions Updated',
682
+ EMBEDDING_GENERATED: 'AI Embedding Generated',
683
+ KNOWLEDGE_BASE_QUERIED: 'AI Knowledge Base Queried',
684
+ MEMORY_CLEARED: 'AI Memory Cleared',
685
+ MEMORY_CREATED: 'AI Memory Created',
686
+ MEMORY_DELETED: 'AI Memory Deleted',
687
+ MEMORY_RECALLED: 'AI Memory Recalled',
688
+ MEMORY_RETRIEVED: 'AI Memory Retrieved',
689
+ MEMORY_STORED: 'AI Memory Stored',
690
+ MEMORY_UPDATED: 'AI Memory Updated',
691
+ PROJECT_CONTEXT_LOADED: 'AI Project Context Loaded',
692
+ RAG_QUERY_EXECUTED: 'AI RAG Query Executed',
693
+
694
+ // ===== USER INTERACTIONS =====
695
+ AUDIO_INPUT_USED: 'AI Audio Input Used',
696
+ AUDIO_OUTPUT_USED: 'AI Audio Output Used',
697
+ CODE_COPIED: 'AI Code Copied',
698
+ CONVERSATION_EXPORTED: 'AI Conversation Exported',
699
+ MESSAGE_COPIED: 'AI Message Copied',
700
+ MODEL_SELECTED: 'AI Model Selected',
701
+ PARAMETER_ADJUSTED: 'AI Parameter Adjusted',
702
+ STREAM_COMPLETED: 'AI Stream Completed',
703
+ STREAM_STARTED: 'AI Stream Started',
704
+ STREAMING_COMPLETED: 'AI Streaming Completed',
705
+ STREAMING_STARTED: 'AI Streaming Started',
706
+
707
+ // ===== WORKSPACE & ORGANIZATION =====
708
+ CONVERSATION_ARCHIVED: 'AI Conversation Archived',
709
+ CONVERSATION_DUPLICATED: 'AI Conversation Duplicated',
710
+ CONVERSATION_MOVED: 'AI Conversation Moved',
711
+ CONVERSATION_PINNED: 'AI Conversation Pinned',
712
+ CONVERSATION_RENAMED: 'AI Conversation Renamed',
713
+ CONVERSATION_SAVED: 'AI Conversation Saved',
714
+ CONVERSATION_SEARCHED: 'AI Conversation Searched',
715
+ FILTER_APPLIED: 'AI Filter Applied',
716
+ FOLDER_CREATED: 'AI Folder Created',
717
+ FOLDER_DELETED: 'AI Folder Deleted',
718
+ FOLDER_RENAMED: 'AI Folder Renamed',
719
+ SEARCH_PERFORMED: 'AI Search Performed',
720
+ TAG_ADDED: 'AI Tag Added',
721
+ TEMPLATE_CREATED: 'AI Template Created',
722
+ TEMPLATE_DELETED: 'AI Template Deleted',
723
+ TEMPLATE_USED: 'AI Template Used',
724
+
725
+ // ===== COLLABORATION & SHARING =====
726
+ COMMENT_ADDED: 'AI Comment Added',
727
+ CONVERSATION_FORKED: 'AI Conversation Forked',
728
+ CONVERSATION_SHARED: 'AI Conversation Shared',
729
+ MEMBER_INVITED: 'AI Member Invited',
730
+ PERMISSION_CHANGED: 'AI Permission Changed',
731
+ TEAM_MEMBER_INVITED: 'AI Team Member Invited',
732
+ TEAM_MEMBER_REMOVED: 'AI Team Member Removed',
733
+ WORKSPACE_CREATED: 'AI Workspace Created',
734
+
735
+ // ===== ARTIFACTS & CANVAS =====
736
+ ARTIFACT_CREATED: 'AI Artifact Created',
737
+ ARTIFACT_EDITED: 'AI Artifact Edited',
738
+ ARTIFACT_EXECUTED: 'AI Artifact Executed',
739
+ ARTIFACT_FORKED: 'AI Artifact Forked',
740
+ ARTIFACT_PUBLISHED: 'AI Artifact Published',
741
+ CANVAS_CLOSED: 'AI Canvas Closed',
742
+ CANVAS_EDITED: 'AI Canvas Edited',
743
+ CANVAS_OPENED: 'AI Canvas Opened',
744
+ CANVAS_SAVED: 'AI Canvas Saved',
745
+ LIVE_PREVIEW_TOGGLED: 'AI Live Preview Toggled',
746
+
747
+ // ===== FEEDBACK & QUALITY =====
748
+ BUG_REPORTED: 'AI Bug Reported',
749
+ FEATURE_REQUESTED: 'AI Feature Requested',
750
+ FEEDBACK_NEGATIVE: 'AI Feedback Negative',
751
+ FEEDBACK_POSITIVE: 'AI Feedback Positive',
752
+ FEEDBACK_PROVIDED: 'AI Feedback Provided',
753
+ HARMFUL_CONTENT_FLAGGED: 'AI Harmful Content Flagged',
754
+ ISSUE_REPORTED: 'AI Issue Reported',
755
+ QUALITY_ISSUE_REPORTED: 'AI Quality Issue Reported',
756
+ RATING_PROVIDED: 'AI Rating Provided',
757
+ RESPONSE_RATED: 'AI Response Rated',
758
+ SAFETY_VIOLATION: 'AI Safety Violation',
759
+
760
+ // ===== SYSTEM & PERFORMANCE =====
761
+ COST_TRACKED: 'AI Cost Tracked',
762
+ ERROR_OCCURRED: 'AI Error Occurred',
763
+ LATENCY_MEASURED: 'AI Latency Measured',
764
+ MODEL_SWITCHED: 'AI Model Switched',
765
+ PERFORMANCE_MEASURED: 'AI Performance Measured',
766
+ RATE_LIMIT_HIT: 'AI Rate Limit Hit',
767
+ SETTINGS_UPDATED: 'AI Settings Updated',
768
+ TOKEN_LIMIT_REACHED: 'AI Token Limit Reached',
769
+ TOKEN_USAGE_TRACKED: 'AI Token Usage Tracked',
770
+ } as const;
771
+
772
+ export type AIEventName = (typeof AI_EVENTS)[keyof typeof AI_EVENTS];
773
+
774
+ /**
775
+ * Valid AI event categories
776
+ */
777
+ export type AIEventCategory =
778
+ | 'ai'
779
+ | 'conversation'
780
+ | 'content'
781
+ | 'artifacts'
782
+ | 'tool'
783
+ | 'feedback'
784
+ | 'system'
785
+ | 'workspace'
786
+ | 'content-generation'
787
+ | 'user-interactions'
788
+ | 'files'
789
+ | 'context'
790
+ | 'collaboration';
791
+
792
+ export interface AIEventSpec<T = any> {
793
+ category: AIEventCategory;
794
+ name: AIEventName;
795
+ properties: T;
796
+ requiredProperties: (keyof T)[];
797
+ }
798
+
799
+ export type AIEventProperties =
800
+ | BaseAIProperties
801
+ | ConversationProperties
802
+ | MessageProperties
803
+ | RegenerationProperties
804
+ | MessageEditProperties
805
+ | BranchProperties
806
+ | TextGenerationProperties
807
+ | CodeGenerationProperties
808
+ | ImageGenerationProperties
809
+ | SummaryProperties
810
+ | TranslationProperties
811
+ | FileUploadProperties
812
+ | FileAnalysisProperties
813
+ | ImageAnalysisProperties
814
+ | WebSearchProperties
815
+ | WebBrowseProperties
816
+ | CitationProperties
817
+ | ToolCallProperties
818
+ | PluginProperties
819
+ | APICallProperties
820
+ | ContextProperties
821
+ | MemoryProperties
822
+ | CustomInstructionsProperties
823
+ | ModelSelectionProperties
824
+ | ParameterAdjustmentProperties
825
+ | VoiceProperties
826
+ | StreamingProperties
827
+ | CopyExportProperties
828
+ | ConversationManagementProperties
829
+ | FolderProperties
830
+ | SearchProperties
831
+ | TemplateProperties
832
+ | ShareProperties
833
+ | WorkspaceProperties
834
+ | TeamProperties
835
+ | CommentProperties
836
+ | ArtifactProperties
837
+ | CanvasProperties
838
+ | FeedbackProperties
839
+ | IssueReportProperties
840
+ | SafetyProperties
841
+ | RateLimitProperties
842
+ | ErrorProperties
843
+ | LatencyProperties
844
+ | CostTrackingProperties;
845
+
846
+ // =============================================================================
847
+ // AI SDK V6 EVENTS & TYPES
848
+ // =============================================================================
849
+
850
+ /**
851
+ * AI SDK v6 event constants
852
+ * For tracking AI SDK operations: agents, completions, tools, streaming, chat
853
+ */
854
+ export const AI_SDK_EVENTS = {
855
+ // Agent events
856
+ AGENT_CREATED: 'ai_sdk_agent_created',
857
+ AGENT_EXECUTION_STARTED: 'ai_sdk_agent_execution_started',
858
+ AGENT_EXECUTION_COMPLETED: 'ai_sdk_agent_execution_completed',
859
+ AGENT_EXECUTION_FAILED: 'ai_sdk_agent_execution_failed',
860
+
861
+ // Completion events
862
+ COMPLETION_REQUESTED: 'ai_sdk_completion_requested',
863
+ COMPLETION_GENERATED: 'ai_sdk_completion_generated',
864
+ COMPLETION_FAILED: 'ai_sdk_completion_failed',
865
+
866
+ // Tool call events
867
+ TOOL_CALL_STARTED: 'ai_sdk_tool_call_started',
868
+ TOOL_CALL_COMPLETED: 'ai_sdk_tool_call_completed',
869
+ TOOL_CALL_FAILED: 'ai_sdk_tool_call_failed',
870
+
871
+ // Streaming events
872
+ STREAM_STARTED: 'ai_sdk_stream_started',
873
+ STREAM_CHUNK_RECEIVED: 'ai_sdk_stream_chunk_received',
874
+ STREAM_COMPLETED: 'ai_sdk_stream_completed',
875
+ STREAM_FAILED: 'ai_sdk_stream_failed',
876
+
877
+ // Chat session events
878
+ CHAT_SESSION_STARTED: 'ai_sdk_chat_session_started',
879
+ CHAT_SESSION_ENDED: 'ai_sdk_chat_session_ended',
880
+ CHAT_MESSAGE_SENT: 'ai_sdk_chat_message_sent',
881
+ CHAT_MESSAGE_RECEIVED: 'ai_sdk_chat_message_received',
882
+
883
+ // E-commerce chatbot events
884
+ CHATBOT_INTENT_DETECTED: 'ai_sdk_chatbot_intent_detected',
885
+ CHATBOT_CART_ASSISTED: 'ai_sdk_chatbot_cart_assisted',
886
+ CHATBOT_ORDER_ASSISTED: 'ai_sdk_chatbot_order_assisted',
887
+ CHATBOT_PRODUCT_RECOMMENDED: 'ai_sdk_chatbot_product_recommended',
888
+
889
+ // Token usage tracking
890
+ TOKEN_USAGE_TRACKED: 'ai_sdk_token_usage_tracked',
891
+
892
+ // Multi-step reasoning
893
+ MULTI_STEP_STARTED: 'ai_sdk_multi_step_started',
894
+ MULTI_STEP_PROGRESSED: 'ai_sdk_multi_step_progressed',
895
+ MULTI_STEP_COMPLETED: 'ai_sdk_multi_step_completed',
896
+ } as const;
897
+
898
+ /**
899
+ * Base properties for AI SDK events
900
+ */
901
+ export interface BaseAISDKProperties {
902
+ model_id: string;
903
+ model_provider?:
904
+ | 'anthropic'
905
+ | 'openai'
906
+ | 'google'
907
+ | 'cohere'
908
+ | 'mistral'
909
+ | 'other'
910
+ | 'perplexity'
911
+ | undefined;
912
+ session_id?: string | undefined;
913
+ user_id?: string | undefined;
914
+ operation_id?: string | undefined;
915
+ conversation_id?: string | undefined;
916
+ message_id?: string | undefined;
917
+ timestamp?: number | undefined;
918
+ }
919
+
920
+ /**
921
+ * Agent execution properties
922
+ */
923
+ export interface AgentProperties extends BaseAISDKProperties, TokenUsageProperties {
924
+ agent_id?: string;
925
+ agent_name?: string;
926
+ agent_type?: string;
927
+ agent_version?: string;
928
+ system_prompt_length?: number;
929
+ tools_available?: string[];
930
+ tools_count?: number;
931
+ execution_time_ms?: number;
932
+ iterations?: number;
933
+ completion_type?: string;
934
+ status?: 'success' | 'failed' | 'pending';
935
+ total_duration_ms?: number;
936
+ step_count?: number;
937
+ retry_count?: number;
938
+ has_tools?: boolean;
939
+ }
940
+
941
+ /**
942
+ * Completion properties
943
+ */
944
+ export interface CompletionProperties
945
+ extends BaseAISDKProperties, TokenUsageProperties, ModelConfigProperties {
946
+ prompt_length?: number;
947
+ completion_length?: number;
948
+ finish_reason?: 'stop' | 'length' | 'content_filter' | 'tool_calls';
949
+ generation_time_ms?: number;
950
+ stream?: boolean;
951
+ completion_type?: string;
952
+ status?: 'success' | 'failed' | 'pending' | 'completed';
953
+ total_duration_ms?: number;
954
+ step_count?: number;
955
+ retry_count?: number;
956
+ has_tools?: boolean;
957
+ agent_id?: string;
958
+ conversation_id?: string;
959
+ }
960
+
961
+ /**
962
+ * Tool call SDK properties (for AI SDK v6 events)
963
+ */
964
+ export interface ToolCallSDKProperties extends BaseAISDKProperties {
965
+ tool_name: string;
966
+ tool_id?: string;
967
+ tool_call_id?: string;
968
+ tool_type?: string;
969
+ input_schema?: Record<string, any>;
970
+ input_size?: number;
971
+ output_schema?: Record<string, any>;
972
+ output_size?: number;
973
+ execution_time_ms?: number;
974
+ success?: boolean;
975
+ result_status?: 'success' | 'error' | 'partial';
976
+ }
977
+
978
+ /**
979
+ * Streaming SDK properties (for AI SDK v6 events)
980
+ */
981
+ export interface StreamingSDKProperties extends BaseAISDKProperties {
982
+ chunk_index?: number | undefined;
983
+ chunks_total?: number | undefined;
984
+ chunk_count?: number | undefined;
985
+ bytes_streamed?: number | undefined;
986
+ stream_duration_ms?: number | undefined;
987
+ first_chunk_time_ms?: number | undefined;
988
+ stream_type?: 'text' | 'audio' | 'video' | 'image' | undefined;
989
+ time_to_first_chunk_ms?: number | undefined;
990
+ chunks_per_second?: number | undefined;
991
+ was_stopped?: boolean | undefined;
992
+ }
993
+
994
+ /**
995
+ * Chat session properties
996
+ */
997
+ export interface SessionProperties extends BaseAISDKProperties, TokenUsageProperties {
998
+ session_id: string;
999
+ session_type?: 'chat' | 'completion' | 'streaming';
1000
+ duration_ms?: number;
1001
+ message_count?: number;
1002
+ tool_calls_count?: number;
1003
+ session_end_reason?: 'user-ended' | 'timeout' | 'error' | 'completed';
1004
+ }
1005
+
1006
+ /**
1007
+ * Chat message properties
1008
+ */
1009
+ export interface ChatMessageProperties extends BaseAISDKProperties, TokenUsageProperties {
1010
+ chat_id?: string;
1011
+ conversation_id?: string;
1012
+ message_id?: string;
1013
+ message_role: 'user' | 'assistant' | 'system' | 'tool';
1014
+ message_length?: number;
1015
+ has_attachments?: boolean;
1016
+ response_time_ms?: number;
1017
+ message_index?: number;
1018
+ has_images?: boolean;
1019
+ parent_message_id?: string;
1020
+ finish_reason?: string;
1021
+ is_streaming?: boolean;
1022
+ }
1023
+
1024
+ /**
1025
+ * E-commerce chatbot properties
1026
+ */
1027
+ export interface ChatbotEcommerceProperties extends BaseAISDKProperties {
1028
+ conversation_id?: string;
1029
+ intent?: string;
1030
+ confidence?: number;
1031
+ product_ids?: string[];
1032
+ product_count?: number;
1033
+ cart_value?: number;
1034
+ order_id?: string;
1035
+ recommendation_type?: string;
1036
+ intent_detected?: string;
1037
+ cart_id?: string;
1038
+ }
1039
+
1040
+ // Re-export AISdkEventSpec from track-ai-sdk for convenience
1041
+ export type { AISdkEventSpec } from './track-ai-sdk';