@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.
- package/README.md +509 -0
- package/dist/ai-YMnynb-t.mjs +3347 -0
- package/dist/ai-YMnynb-t.mjs.map +1 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/client-CTzJVFU5.mjs +9 -0
- package/dist/client-CTzJVFU5.mjs.map +1 -0
- package/dist/client-CcFTauAh.mjs +54 -0
- package/dist/client-CcFTauAh.mjs.map +1 -0
- package/dist/client-CeOLjbac.mjs +281 -0
- package/dist/client-CeOLjbac.mjs.map +1 -0
- package/dist/client-D339NFJS.mjs +267 -0
- package/dist/client-D339NFJS.mjs.map +1 -0
- package/dist/client-next.d.mts +62 -0
- package/dist/client-next.d.mts.map +1 -0
- package/dist/client-next.mjs +525 -0
- package/dist/client-next.mjs.map +1 -0
- package/dist/client.d.mts +30 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +186 -0
- package/dist/client.mjs.map +1 -0
- package/dist/config-DPS6bSYo.d.mts +34 -0
- package/dist/config-DPS6bSYo.d.mts.map +1 -0
- package/dist/config-P6P5adJg.mjs +287 -0
- package/dist/config-P6P5adJg.mjs.map +1 -0
- package/dist/console-8bND3mMU.mjs +128 -0
- package/dist/console-8bND3mMU.mjs.map +1 -0
- package/dist/ecommerce-Cgu4wlux.mjs +993 -0
- package/dist/ecommerce-Cgu4wlux.mjs.map +1 -0
- package/dist/emitters-6-nKo8i-.mjs +208 -0
- package/dist/emitters-6-nKo8i-.mjs.map +1 -0
- package/dist/emitters-DldkVSPp.d.mts +12 -0
- package/dist/emitters-DldkVSPp.d.mts.map +1 -0
- package/dist/index-BfNWgfa5.d.mts +1494 -0
- package/dist/index-BfNWgfa5.d.mts.map +1 -0
- package/dist/index-BkIWe--N.d.mts +953 -0
- package/dist/index-BkIWe--N.d.mts.map +1 -0
- package/dist/index-jPzXRn52.d.mts +184 -0
- package/dist/index-jPzXRn52.d.mts.map +1 -0
- package/dist/manager-DvRRjza6.d.mts +76 -0
- package/dist/manager-DvRRjza6.d.mts.map +1 -0
- package/dist/posthog-bootstrap-CYfIy_WS.mjs +1769 -0
- package/dist/posthog-bootstrap-CYfIy_WS.mjs.map +1 -0
- package/dist/posthog-bootstrap-DWxFrxlt.d.mts +81 -0
- package/dist/posthog-bootstrap-DWxFrxlt.d.mts.map +1 -0
- package/dist/providers-http-client.d.mts +37 -0
- package/dist/providers-http-client.d.mts.map +1 -0
- package/dist/providers-http-client.mjs +320 -0
- package/dist/providers-http-client.mjs.map +1 -0
- package/dist/providers-http-server.d.mts +31 -0
- package/dist/providers-http-server.d.mts.map +1 -0
- package/dist/providers-http-server.mjs +297 -0
- package/dist/providers-http-server.mjs.map +1 -0
- package/dist/providers-http.d.mts +46 -0
- package/dist/providers-http.d.mts.map +1 -0
- package/dist/providers-http.mjs +4 -0
- package/dist/server-edge.d.mts +9 -0
- package/dist/server-edge.d.mts.map +1 -0
- package/dist/server-edge.mjs +373 -0
- package/dist/server-edge.mjs.map +1 -0
- package/dist/server-next.d.mts +67 -0
- package/dist/server-next.d.mts.map +1 -0
- package/dist/server-next.mjs +193 -0
- package/dist/server-next.mjs.map +1 -0
- package/dist/server.d.mts +10 -0
- package/dist/server.mjs +7 -0
- package/dist/service-cYtBBL8x.mjs +945 -0
- package/dist/service-cYtBBL8x.mjs.map +1 -0
- package/dist/shared.d.mts +16 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +93 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/types-BxBnNQ0V.d.mts +354 -0
- package/dist/types-BxBnNQ0V.d.mts.map +1 -0
- package/dist/types-CBvxUEaF.d.mts +216 -0
- package/dist/types-CBvxUEaF.d.mts.map +1 -0
- package/dist/types.d.mts +4 -0
- package/dist/types.mjs +0 -0
- package/dist/vercel-types-lwakUfoI.d.mts +102 -0
- package/dist/vercel-types-lwakUfoI.d.mts.map +1 -0
- package/package.json +129 -0
- package/src/client/index.ts +164 -0
- package/src/client/manager.ts +71 -0
- package/src/client/next/components.tsx +270 -0
- package/src/client/next/hooks.ts +217 -0
- package/src/client/next/manager.ts +141 -0
- package/src/client/next.ts +144 -0
- package/src/client-next.ts +101 -0
- package/src/client.ts +89 -0
- package/src/examples/ai-sdk-patterns.ts +583 -0
- package/src/examples/emitter-patterns.ts +476 -0
- package/src/examples/nextjs-emitter-patterns.tsx +403 -0
- package/src/next/app-router.tsx +564 -0
- package/src/next/client.ts +419 -0
- package/src/next/index.ts +84 -0
- package/src/next/middleware.ts +429 -0
- package/src/next/rsc.tsx +300 -0
- package/src/next/server.ts +253 -0
- package/src/next/types.d.ts +220 -0
- package/src/providers/base-provider.ts +419 -0
- package/src/providers/console/client.ts +10 -0
- package/src/providers/console/index.ts +152 -0
- package/src/providers/console/server.ts +6 -0
- package/src/providers/console/types.ts +15 -0
- package/src/providers/http/client.ts +464 -0
- package/src/providers/http/index.ts +30 -0
- package/src/providers/http/server.ts +396 -0
- package/src/providers/http/types.ts +135 -0
- package/src/providers/posthog/client.ts +518 -0
- package/src/providers/posthog/index.ts +11 -0
- package/src/providers/posthog/server.ts +329 -0
- package/src/providers/posthog/types.ts +104 -0
- package/src/providers/segment/client.ts +113 -0
- package/src/providers/segment/index.ts +11 -0
- package/src/providers/segment/server.ts +115 -0
- package/src/providers/segment/types.ts +51 -0
- package/src/providers/vercel/client.ts +102 -0
- package/src/providers/vercel/index.ts +11 -0
- package/src/providers/vercel/server.ts +89 -0
- package/src/providers/vercel/types.ts +27 -0
- package/src/server/index.ts +103 -0
- package/src/server/manager.ts +62 -0
- package/src/server/next.ts +210 -0
- package/src/server-edge.ts +442 -0
- package/src/server-next.ts +39 -0
- package/src/server.ts +106 -0
- package/src/shared/emitters/ai/README.md +981 -0
- package/src/shared/emitters/ai/events/agent.ts +130 -0
- package/src/shared/emitters/ai/events/artifacts.ts +167 -0
- package/src/shared/emitters/ai/events/chat.ts +126 -0
- package/src/shared/emitters/ai/events/chatbot-ecommerce.ts +133 -0
- package/src/shared/emitters/ai/events/completion.ts +103 -0
- package/src/shared/emitters/ai/events/content-generation.ts +347 -0
- package/src/shared/emitters/ai/events/conversation.ts +332 -0
- package/src/shared/emitters/ai/events/product-features.ts +1402 -0
- package/src/shared/emitters/ai/events/streaming.ts +114 -0
- package/src/shared/emitters/ai/events/tool.ts +93 -0
- package/src/shared/emitters/ai/index.ts +69 -0
- package/src/shared/emitters/ai/track-ai-sdk.ts +74 -0
- package/src/shared/emitters/ai/track-ai.ts +50 -0
- package/src/shared/emitters/ai/types.ts +1041 -0
- package/src/shared/emitters/ai/utils.ts +468 -0
- package/src/shared/emitters/ecommerce/events/cart-checkout.ts +106 -0
- package/src/shared/emitters/ecommerce/events/coupon.ts +49 -0
- package/src/shared/emitters/ecommerce/events/engagement.ts +61 -0
- package/src/shared/emitters/ecommerce/events/marketplace.ts +119 -0
- package/src/shared/emitters/ecommerce/events/order.ts +199 -0
- package/src/shared/emitters/ecommerce/events/product.ts +205 -0
- package/src/shared/emitters/ecommerce/events/registry.ts +123 -0
- package/src/shared/emitters/ecommerce/events/wishlist-sharing.ts +140 -0
- package/src/shared/emitters/ecommerce/index.ts +46 -0
- package/src/shared/emitters/ecommerce/track-ecommerce.ts +53 -0
- package/src/shared/emitters/ecommerce/types.ts +314 -0
- package/src/shared/emitters/ecommerce/utils.ts +216 -0
- package/src/shared/emitters/emitter-types.ts +974 -0
- package/src/shared/emitters/emitters.ts +292 -0
- package/src/shared/emitters/helpers.ts +419 -0
- package/src/shared/emitters/index.ts +66 -0
- package/src/shared/index.ts +142 -0
- package/src/shared/ingestion/index.ts +66 -0
- package/src/shared/ingestion/schemas.ts +386 -0
- package/src/shared/ingestion/service.ts +628 -0
- package/src/shared/node22-features.ts +848 -0
- package/src/shared/providers/console-provider.ts +160 -0
- package/src/shared/types/base-types.ts +54 -0
- package/src/shared/types/console-types.ts +19 -0
- package/src/shared/types/posthog-types.ts +131 -0
- package/src/shared/types/segment-types.ts +15 -0
- package/src/shared/types/types.ts +397 -0
- package/src/shared/types/vercel-types.ts +19 -0
- package/src/shared/utils/config-client.ts +19 -0
- package/src/shared/utils/config.ts +250 -0
- package/src/shared/utils/emitter-adapter.ts +212 -0
- package/src/shared/utils/manager.test.ts +36 -0
- package/src/shared/utils/manager.ts +1322 -0
- package/src/shared/utils/posthog-bootstrap.ts +136 -0
- package/src/shared/utils/posthog-client-utils.ts +48 -0
- package/src/shared/utils/posthog-next-utils.ts +282 -0
- package/src/shared/utils/posthog-server-utils.ts +210 -0
- package/src/shared/utils/rate-limit.ts +289 -0
- package/src/shared/utils/security.ts +545 -0
- package/src/shared/utils/validation-client.ts +161 -0
- package/src/shared/utils/validation.ts +399 -0
- package/src/shared.ts +155 -0
- package/src/types/index.ts +62 -0
|
@@ -0,0 +1,3347 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
|
|
2
|
+
import { o as track } from "./emitters-6-nKo8i-.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/emitters/ai/types.ts
|
|
5
|
+
const AI_EVENTS = {
|
|
6
|
+
BRANCH_CREATED: "AI Branch Created",
|
|
7
|
+
BRANCH_MERGED: "AI Branch Merged",
|
|
8
|
+
CONVERSATION_CONTINUED: "AI Conversation Continued",
|
|
9
|
+
CONVERSATION_DELETED: "AI Conversation Deleted",
|
|
10
|
+
CONVERSATION_ENDED: "AI Conversation Ended",
|
|
11
|
+
CONVERSATION_RESUMED: "AI Conversation Resumed",
|
|
12
|
+
CONVERSATION_STARTED: "AI Conversation Started",
|
|
13
|
+
MESSAGE_DELETED: "AI Message Deleted",
|
|
14
|
+
MESSAGE_EDITED: "AI Message Edited",
|
|
15
|
+
MESSAGE_RECEIVED: "AI Message Received",
|
|
16
|
+
MESSAGE_REGENERATED: "AI Message Regenerated",
|
|
17
|
+
MESSAGE_SENT: "AI Message Sent",
|
|
18
|
+
STOP_GENERATION: "AI Stop Generation",
|
|
19
|
+
STREAMING_CHUNK_RECEIVED: "AI Streaming Chunk Received",
|
|
20
|
+
CODE_DEBUGGED: "AI Code Debugged",
|
|
21
|
+
CODE_EDITED: "AI Code Edited",
|
|
22
|
+
CODE_EXECUTED: "AI Code Executed",
|
|
23
|
+
CODE_EXPLAINED: "AI Code Explained",
|
|
24
|
+
CODE_GENERATED: "AI Code Generated",
|
|
25
|
+
CODE_REFACTORED: "AI Code Refactored",
|
|
26
|
+
CODE_TRANSLATED: "AI Code Translated",
|
|
27
|
+
COMPLETION_GENERATED: "AI Completion Generated",
|
|
28
|
+
CONTENT_COPIED: "AI Content Copied",
|
|
29
|
+
CONTENT_DOWNLOADED: "AI Content Downloaded",
|
|
30
|
+
CONTENT_REWRITTEN: "AI Content Rewritten",
|
|
31
|
+
CONTENT_SHARED: "AI Content Shared",
|
|
32
|
+
DIFF_VIEWED: "AI Diff Viewed",
|
|
33
|
+
DOCUMENT_CREATED: "AI Document Created",
|
|
34
|
+
EMAIL_DRAFTED: "AI Email Drafted",
|
|
35
|
+
IMAGE_EDITED: "AI Image Edited",
|
|
36
|
+
IMAGE_GENERATED: "AI Image Generated",
|
|
37
|
+
IMAGE_REVISED: "AI Image Revised",
|
|
38
|
+
INLINE_EDIT_APPLIED: "AI Inline Edit Applied",
|
|
39
|
+
OUTLINE_CREATED: "AI Outline Created",
|
|
40
|
+
REWRITE_GENERATED: "AI Rewrite Generated",
|
|
41
|
+
SUGGESTION_ACCEPTED: "AI Suggestion Accepted",
|
|
42
|
+
SUGGESTION_REJECTED: "AI Suggestion Rejected",
|
|
43
|
+
SUMMARY_GENERATED: "AI Summary Generated",
|
|
44
|
+
TEXT_GENERATED: "AI Text Generated",
|
|
45
|
+
TEXT_TRANSLATED: "AI Text Translated",
|
|
46
|
+
TRANSLATION_GENERATED: "AI Translation Generated",
|
|
47
|
+
BATCH_FILES_PROCESSED: "AI Batch Files Processed",
|
|
48
|
+
FILE_ANALYZED: "AI File Analyzed",
|
|
49
|
+
FILE_DELETED: "AI File Deleted",
|
|
50
|
+
FILE_DOWNLOADED: "AI File Downloaded",
|
|
51
|
+
FILE_PROCESSED: "AI File Processed",
|
|
52
|
+
FILE_PROCESSING_FAILED: "AI File Processing Failed",
|
|
53
|
+
FILE_REFERENCED: "AI File Referenced",
|
|
54
|
+
FILE_UPLOADED: "AI File Uploaded",
|
|
55
|
+
IMAGE_ANALYZED: "AI Image Analyzed",
|
|
56
|
+
IMAGE_UPLOADED: "AI Image Uploaded",
|
|
57
|
+
BROWSE_SESSION_STARTED: "AI Browse Session Started",
|
|
58
|
+
CITATION_ADDED: "AI Citation Added",
|
|
59
|
+
CITATION_PROVIDED: "AI Citation Provided",
|
|
60
|
+
EXTERNAL_SOURCE_ACCESSED: "AI External Source Accessed",
|
|
61
|
+
PAGE_CONTENT_FETCHED: "AI Page Content Fetched",
|
|
62
|
+
SEARCH_RESULTS_RANKED: "AI Search Results Ranked",
|
|
63
|
+
WEB_BROWSED: "AI Web Browsed",
|
|
64
|
+
WEB_SEARCH_PERFORMED: "AI Web Search Performed",
|
|
65
|
+
WEB_SEARCHED: "AI Web Searched",
|
|
66
|
+
API_CALLED: "AI API Called",
|
|
67
|
+
API_REQUEST_MADE: "AI API Request Made",
|
|
68
|
+
EXTENSION_USED: "AI Extension Used",
|
|
69
|
+
FUNCTION_EXECUTED: "AI Function Executed",
|
|
70
|
+
PLUGIN_ACTIVATED: "AI Plugin Activated",
|
|
71
|
+
PLUGIN_DISABLED: "AI Plugin Disabled",
|
|
72
|
+
PLUGIN_ENABLED: "AI Plugin Enabled",
|
|
73
|
+
PLUGIN_USED: "AI Plugin Used",
|
|
74
|
+
TOOL_CALL_COMPLETED: "AI Tool Call Completed",
|
|
75
|
+
TOOL_CALL_FAILED: "AI Tool Call Failed",
|
|
76
|
+
TOOL_CALL_STARTED: "AI Tool Call Started",
|
|
77
|
+
TOOL_CALLED: "AI Tool Called",
|
|
78
|
+
TOOL_FAILED: "AI Tool Failed",
|
|
79
|
+
CONTEXT_CLEARED: "AI Context Cleared",
|
|
80
|
+
CONTEXT_PRUNED: "AI Context Pruned",
|
|
81
|
+
CONTEXT_UPDATED: "AI Context Updated",
|
|
82
|
+
CONTEXT_WINDOW_UPDATED: "AI Context Window Updated",
|
|
83
|
+
CUSTOM_INSTRUCTIONS_CLEARED: "AI Custom Instructions Cleared",
|
|
84
|
+
CUSTOM_INSTRUCTIONS_CREATED: "AI Custom Instructions Created",
|
|
85
|
+
CUSTOM_INSTRUCTIONS_UPDATED: "AI Custom Instructions Updated",
|
|
86
|
+
EMBEDDING_GENERATED: "AI Embedding Generated",
|
|
87
|
+
KNOWLEDGE_BASE_QUERIED: "AI Knowledge Base Queried",
|
|
88
|
+
MEMORY_CLEARED: "AI Memory Cleared",
|
|
89
|
+
MEMORY_CREATED: "AI Memory Created",
|
|
90
|
+
MEMORY_DELETED: "AI Memory Deleted",
|
|
91
|
+
MEMORY_RECALLED: "AI Memory Recalled",
|
|
92
|
+
MEMORY_RETRIEVED: "AI Memory Retrieved",
|
|
93
|
+
MEMORY_STORED: "AI Memory Stored",
|
|
94
|
+
MEMORY_UPDATED: "AI Memory Updated",
|
|
95
|
+
PROJECT_CONTEXT_LOADED: "AI Project Context Loaded",
|
|
96
|
+
RAG_QUERY_EXECUTED: "AI RAG Query Executed",
|
|
97
|
+
AUDIO_INPUT_USED: "AI Audio Input Used",
|
|
98
|
+
AUDIO_OUTPUT_USED: "AI Audio Output Used",
|
|
99
|
+
CODE_COPIED: "AI Code Copied",
|
|
100
|
+
CONVERSATION_EXPORTED: "AI Conversation Exported",
|
|
101
|
+
MESSAGE_COPIED: "AI Message Copied",
|
|
102
|
+
MODEL_SELECTED: "AI Model Selected",
|
|
103
|
+
PARAMETER_ADJUSTED: "AI Parameter Adjusted",
|
|
104
|
+
STREAM_COMPLETED: "AI Stream Completed",
|
|
105
|
+
STREAM_STARTED: "AI Stream Started",
|
|
106
|
+
STREAMING_COMPLETED: "AI Streaming Completed",
|
|
107
|
+
STREAMING_STARTED: "AI Streaming Started",
|
|
108
|
+
CONVERSATION_ARCHIVED: "AI Conversation Archived",
|
|
109
|
+
CONVERSATION_DUPLICATED: "AI Conversation Duplicated",
|
|
110
|
+
CONVERSATION_MOVED: "AI Conversation Moved",
|
|
111
|
+
CONVERSATION_PINNED: "AI Conversation Pinned",
|
|
112
|
+
CONVERSATION_RENAMED: "AI Conversation Renamed",
|
|
113
|
+
CONVERSATION_SAVED: "AI Conversation Saved",
|
|
114
|
+
CONVERSATION_SEARCHED: "AI Conversation Searched",
|
|
115
|
+
FILTER_APPLIED: "AI Filter Applied",
|
|
116
|
+
FOLDER_CREATED: "AI Folder Created",
|
|
117
|
+
FOLDER_DELETED: "AI Folder Deleted",
|
|
118
|
+
FOLDER_RENAMED: "AI Folder Renamed",
|
|
119
|
+
SEARCH_PERFORMED: "AI Search Performed",
|
|
120
|
+
TAG_ADDED: "AI Tag Added",
|
|
121
|
+
TEMPLATE_CREATED: "AI Template Created",
|
|
122
|
+
TEMPLATE_DELETED: "AI Template Deleted",
|
|
123
|
+
TEMPLATE_USED: "AI Template Used",
|
|
124
|
+
COMMENT_ADDED: "AI Comment Added",
|
|
125
|
+
CONVERSATION_FORKED: "AI Conversation Forked",
|
|
126
|
+
CONVERSATION_SHARED: "AI Conversation Shared",
|
|
127
|
+
MEMBER_INVITED: "AI Member Invited",
|
|
128
|
+
PERMISSION_CHANGED: "AI Permission Changed",
|
|
129
|
+
TEAM_MEMBER_INVITED: "AI Team Member Invited",
|
|
130
|
+
TEAM_MEMBER_REMOVED: "AI Team Member Removed",
|
|
131
|
+
WORKSPACE_CREATED: "AI Workspace Created",
|
|
132
|
+
ARTIFACT_CREATED: "AI Artifact Created",
|
|
133
|
+
ARTIFACT_EDITED: "AI Artifact Edited",
|
|
134
|
+
ARTIFACT_EXECUTED: "AI Artifact Executed",
|
|
135
|
+
ARTIFACT_FORKED: "AI Artifact Forked",
|
|
136
|
+
ARTIFACT_PUBLISHED: "AI Artifact Published",
|
|
137
|
+
CANVAS_CLOSED: "AI Canvas Closed",
|
|
138
|
+
CANVAS_EDITED: "AI Canvas Edited",
|
|
139
|
+
CANVAS_OPENED: "AI Canvas Opened",
|
|
140
|
+
CANVAS_SAVED: "AI Canvas Saved",
|
|
141
|
+
LIVE_PREVIEW_TOGGLED: "AI Live Preview Toggled",
|
|
142
|
+
BUG_REPORTED: "AI Bug Reported",
|
|
143
|
+
FEATURE_REQUESTED: "AI Feature Requested",
|
|
144
|
+
FEEDBACK_NEGATIVE: "AI Feedback Negative",
|
|
145
|
+
FEEDBACK_POSITIVE: "AI Feedback Positive",
|
|
146
|
+
FEEDBACK_PROVIDED: "AI Feedback Provided",
|
|
147
|
+
HARMFUL_CONTENT_FLAGGED: "AI Harmful Content Flagged",
|
|
148
|
+
ISSUE_REPORTED: "AI Issue Reported",
|
|
149
|
+
QUALITY_ISSUE_REPORTED: "AI Quality Issue Reported",
|
|
150
|
+
RATING_PROVIDED: "AI Rating Provided",
|
|
151
|
+
RESPONSE_RATED: "AI Response Rated",
|
|
152
|
+
SAFETY_VIOLATION: "AI Safety Violation",
|
|
153
|
+
COST_TRACKED: "AI Cost Tracked",
|
|
154
|
+
ERROR_OCCURRED: "AI Error Occurred",
|
|
155
|
+
LATENCY_MEASURED: "AI Latency Measured",
|
|
156
|
+
MODEL_SWITCHED: "AI Model Switched",
|
|
157
|
+
PERFORMANCE_MEASURED: "AI Performance Measured",
|
|
158
|
+
RATE_LIMIT_HIT: "AI Rate Limit Hit",
|
|
159
|
+
SETTINGS_UPDATED: "AI Settings Updated",
|
|
160
|
+
TOKEN_LIMIT_REACHED: "AI Token Limit Reached",
|
|
161
|
+
TOKEN_USAGE_TRACKED: "AI Token Usage Tracked"
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* AI SDK v6 event constants
|
|
165
|
+
* For tracking AI SDK operations: agents, completions, tools, streaming, chat
|
|
166
|
+
*/
|
|
167
|
+
const AI_SDK_EVENTS = {
|
|
168
|
+
AGENT_CREATED: "ai_sdk_agent_created",
|
|
169
|
+
AGENT_EXECUTION_STARTED: "ai_sdk_agent_execution_started",
|
|
170
|
+
AGENT_EXECUTION_COMPLETED: "ai_sdk_agent_execution_completed",
|
|
171
|
+
AGENT_EXECUTION_FAILED: "ai_sdk_agent_execution_failed",
|
|
172
|
+
COMPLETION_REQUESTED: "ai_sdk_completion_requested",
|
|
173
|
+
COMPLETION_GENERATED: "ai_sdk_completion_generated",
|
|
174
|
+
COMPLETION_FAILED: "ai_sdk_completion_failed",
|
|
175
|
+
TOOL_CALL_STARTED: "ai_sdk_tool_call_started",
|
|
176
|
+
TOOL_CALL_COMPLETED: "ai_sdk_tool_call_completed",
|
|
177
|
+
TOOL_CALL_FAILED: "ai_sdk_tool_call_failed",
|
|
178
|
+
STREAM_STARTED: "ai_sdk_stream_started",
|
|
179
|
+
STREAM_CHUNK_RECEIVED: "ai_sdk_stream_chunk_received",
|
|
180
|
+
STREAM_COMPLETED: "ai_sdk_stream_completed",
|
|
181
|
+
STREAM_FAILED: "ai_sdk_stream_failed",
|
|
182
|
+
CHAT_SESSION_STARTED: "ai_sdk_chat_session_started",
|
|
183
|
+
CHAT_SESSION_ENDED: "ai_sdk_chat_session_ended",
|
|
184
|
+
CHAT_MESSAGE_SENT: "ai_sdk_chat_message_sent",
|
|
185
|
+
CHAT_MESSAGE_RECEIVED: "ai_sdk_chat_message_received",
|
|
186
|
+
CHATBOT_INTENT_DETECTED: "ai_sdk_chatbot_intent_detected",
|
|
187
|
+
CHATBOT_CART_ASSISTED: "ai_sdk_chatbot_cart_assisted",
|
|
188
|
+
CHATBOT_ORDER_ASSISTED: "ai_sdk_chatbot_order_assisted",
|
|
189
|
+
CHATBOT_PRODUCT_RECOMMENDED: "ai_sdk_chatbot_product_recommended",
|
|
190
|
+
TOKEN_USAGE_TRACKED: "ai_sdk_token_usage_tracked",
|
|
191
|
+
MULTI_STEP_STARTED: "ai_sdk_multi_step_started",
|
|
192
|
+
MULTI_STEP_PROGRESSED: "ai_sdk_multi_step_progressed",
|
|
193
|
+
MULTI_STEP_COMPLETED: "ai_sdk_multi_step_completed"
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/shared/emitters/ai/utils.ts
|
|
198
|
+
/**
|
|
199
|
+
* Remove undefined and null values from an object
|
|
200
|
+
*/
|
|
201
|
+
function cleanProperties(props) {
|
|
202
|
+
const cleaned = {};
|
|
203
|
+
for (const key in props) {
|
|
204
|
+
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
205
|
+
const value = props[key];
|
|
206
|
+
if (value !== void 0 && value !== null) cleaned[key] = value;
|
|
207
|
+
}
|
|
208
|
+
return cleaned;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Validate that required properties are present
|
|
212
|
+
*/
|
|
213
|
+
function validateRequiredProperties(properties, required) {
|
|
214
|
+
const missing = [];
|
|
215
|
+
for (const key of required) if (properties[key] === void 0 || properties[key] === null) missing.push(String(key));
|
|
216
|
+
if (missing.length > 0) throw new Error(`Missing required properties: ${missing.join(", ")}`);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Normalize base AI operation properties
|
|
220
|
+
*/
|
|
221
|
+
function normalizeBaseProperties(props) {
|
|
222
|
+
return {
|
|
223
|
+
model_id: props.model_id,
|
|
224
|
+
agent_id: props.agent_id,
|
|
225
|
+
agent_name: props.agent_name,
|
|
226
|
+
conversation_id: props.conversation_id,
|
|
227
|
+
session_id: props.session_id,
|
|
228
|
+
user_id: props.user_id,
|
|
229
|
+
operation_id: props.operation_id,
|
|
230
|
+
model_provider: props.model_provider
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Normalize token usage properties
|
|
235
|
+
*/
|
|
236
|
+
function normalizeTokenUsage(props) {
|
|
237
|
+
const normalized = {};
|
|
238
|
+
if (props.input_tokens !== void 0) normalized.input_tokens = Math.max(0, props.input_tokens);
|
|
239
|
+
if (props.output_tokens !== void 0) normalized.output_tokens = Math.max(0, props.output_tokens);
|
|
240
|
+
if (props.total_tokens !== void 0) normalized.total_tokens = Math.max(0, props.total_tokens);
|
|
241
|
+
else if (normalized.input_tokens !== void 0 && normalized.output_tokens !== void 0) normalized.total_tokens = normalized.input_tokens + normalized.output_tokens;
|
|
242
|
+
if (props.cost !== void 0) {
|
|
243
|
+
normalized.cost = Math.max(0, props.cost);
|
|
244
|
+
normalized.cost_currency = props.cost_currency ?? "USD";
|
|
245
|
+
}
|
|
246
|
+
return normalized;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Normalize model configuration properties
|
|
250
|
+
*/
|
|
251
|
+
function normalizeModelConfig(props) {
|
|
252
|
+
const normalized = {};
|
|
253
|
+
if (props.temperature !== void 0) normalized.temperature = Math.max(0, Math.min(2, props.temperature));
|
|
254
|
+
if (props.max_tokens !== void 0) normalized.max_tokens = Math.max(1, props.max_tokens);
|
|
255
|
+
if (props.max_output_tokens !== void 0) normalized.max_output_tokens = Math.max(1, props.max_output_tokens);
|
|
256
|
+
if (props.top_p !== void 0) normalized.top_p = Math.max(0, Math.min(1, props.top_p));
|
|
257
|
+
if (props.frequency_penalty !== void 0) normalized.frequency_penalty = Math.max(-2, Math.min(2, props.frequency_penalty));
|
|
258
|
+
if (props.presence_penalty !== void 0) normalized.presence_penalty = Math.max(-2, Math.min(2, props.presence_penalty));
|
|
259
|
+
if (props.seed !== void 0) normalized.seed = props.seed;
|
|
260
|
+
if (props.stop_sequences !== void 0) normalized.stop_sequences = props.stop_sequences;
|
|
261
|
+
return normalized;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Calculate cost based on token usage and model pricing
|
|
265
|
+
*/
|
|
266
|
+
function calculateCost(usage, pricing) {
|
|
267
|
+
let cost = 0;
|
|
268
|
+
if (usage.input_tokens && pricing.input_price_per_1k) cost += usage.input_tokens / 1e3 * pricing.input_price_per_1k;
|
|
269
|
+
if (usage.output_tokens && pricing.output_price_per_1k) cost += usage.output_tokens / 1e3 * pricing.output_price_per_1k;
|
|
270
|
+
return cost;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Extract model provider from model ID
|
|
274
|
+
*/
|
|
275
|
+
function extractModelProvider(modelId) {
|
|
276
|
+
const lowercaseId = modelId.toLowerCase();
|
|
277
|
+
if (lowercaseId.includes("claude") || lowercaseId.includes("anthropic")) return "anthropic";
|
|
278
|
+
if (lowercaseId.includes("gpt") || lowercaseId.includes("openai")) return "openai";
|
|
279
|
+
if (lowercaseId.includes("gemini") || lowercaseId.includes("google")) return "google";
|
|
280
|
+
if (lowercaseId.includes("pplx") || lowercaseId.includes("perplexity")) return "perplexity";
|
|
281
|
+
return "other";
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Generate a unique operation ID
|
|
285
|
+
*/
|
|
286
|
+
function generateOperationId(prefix = "ai") {
|
|
287
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Sanitize error message for tracking
|
|
291
|
+
*/
|
|
292
|
+
function sanitizeErrorMessage(error) {
|
|
293
|
+
return (typeof error === "string" ? error : error.message).replaceAll(/api[\s_\-]?keys?[\s:=]+[\w-]+/gi, "api_key=***").replaceAll(/tokens?[\s:=]+[\w-]+/gi, "token=***").replaceAll(/passwords?[\s:=]+[\w-]+/gi, "password=***").replaceAll(/secrets?[\s:=]+[\w-]+/gi, "secret=***").slice(0, 500);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Calculate metrics for completion events
|
|
297
|
+
*/
|
|
298
|
+
function calculateCompletionMetrics(startTime, endTime, tokenUsage) {
|
|
299
|
+
const duration_ms = endTime - startTime;
|
|
300
|
+
const metrics = { duration_ms };
|
|
301
|
+
if (tokenUsage?.total_tokens && duration_ms > 0) metrics.tokens_per_second = tokenUsage.total_tokens / duration_ms * 1e3;
|
|
302
|
+
return metrics;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Detect intent from chat message
|
|
306
|
+
*/
|
|
307
|
+
function detectIntent(message) {
|
|
308
|
+
const lowercase = message.toLowerCase();
|
|
309
|
+
for (const [intent, patterns] of Object.entries({
|
|
310
|
+
"order-tracking": [
|
|
311
|
+
"track",
|
|
312
|
+
"order status",
|
|
313
|
+
"shipping",
|
|
314
|
+
"delivery",
|
|
315
|
+
"where is my",
|
|
316
|
+
"when will",
|
|
317
|
+
"my order"
|
|
318
|
+
],
|
|
319
|
+
complaint: [
|
|
320
|
+
"disappointed",
|
|
321
|
+
"angry",
|
|
322
|
+
"frustrated",
|
|
323
|
+
"terrible",
|
|
324
|
+
"worst",
|
|
325
|
+
"complain",
|
|
326
|
+
"unhappy"
|
|
327
|
+
],
|
|
328
|
+
"returns-exchanges": [
|
|
329
|
+
"return",
|
|
330
|
+
"refund",
|
|
331
|
+
"exchange",
|
|
332
|
+
"cancel order",
|
|
333
|
+
"send back"
|
|
334
|
+
],
|
|
335
|
+
"product-search": [
|
|
336
|
+
"looking for",
|
|
337
|
+
"search for",
|
|
338
|
+
"find",
|
|
339
|
+
"show me",
|
|
340
|
+
"need",
|
|
341
|
+
"want to buy",
|
|
342
|
+
"shopping for"
|
|
343
|
+
],
|
|
344
|
+
"product-inquiry": [
|
|
345
|
+
"tell me about",
|
|
346
|
+
"details",
|
|
347
|
+
"specs",
|
|
348
|
+
"features",
|
|
349
|
+
"price",
|
|
350
|
+
"available",
|
|
351
|
+
"in stock"
|
|
352
|
+
],
|
|
353
|
+
"product-comparison": [
|
|
354
|
+
"compare",
|
|
355
|
+
"difference between",
|
|
356
|
+
"which is better",
|
|
357
|
+
"vs",
|
|
358
|
+
" or ",
|
|
359
|
+
"better than"
|
|
360
|
+
],
|
|
361
|
+
"cart-management": [
|
|
362
|
+
"add to cart",
|
|
363
|
+
"remove from cart",
|
|
364
|
+
"cart",
|
|
365
|
+
"shopping bag",
|
|
366
|
+
"my items"
|
|
367
|
+
],
|
|
368
|
+
"checkout-help": [
|
|
369
|
+
"checkout",
|
|
370
|
+
"payment",
|
|
371
|
+
"pay",
|
|
372
|
+
"purchase",
|
|
373
|
+
"buy now",
|
|
374
|
+
"complete order"
|
|
375
|
+
],
|
|
376
|
+
feedback: [
|
|
377
|
+
"review",
|
|
378
|
+
"feedback",
|
|
379
|
+
"rate",
|
|
380
|
+
"experience",
|
|
381
|
+
"satisfied"
|
|
382
|
+
]
|
|
383
|
+
})) if (patterns.some((pattern) => lowercase.includes(pattern))) return intent;
|
|
384
|
+
return "general-inquiry";
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Detect sentiment from message
|
|
388
|
+
*/
|
|
389
|
+
function detectSentiment(message) {
|
|
390
|
+
const lowercase = message.toLowerCase();
|
|
391
|
+
const positiveWords = [
|
|
392
|
+
"great",
|
|
393
|
+
"love",
|
|
394
|
+
"excellent",
|
|
395
|
+
"perfect",
|
|
396
|
+
"amazing",
|
|
397
|
+
"wonderful",
|
|
398
|
+
"awesome",
|
|
399
|
+
"fantastic",
|
|
400
|
+
"helpful",
|
|
401
|
+
"thank"
|
|
402
|
+
];
|
|
403
|
+
const negativeWords = [
|
|
404
|
+
"bad",
|
|
405
|
+
"terrible",
|
|
406
|
+
"awful",
|
|
407
|
+
"disappointed",
|
|
408
|
+
"angry",
|
|
409
|
+
"frustrated",
|
|
410
|
+
"annoyed",
|
|
411
|
+
"useless",
|
|
412
|
+
"worst",
|
|
413
|
+
"hate"
|
|
414
|
+
];
|
|
415
|
+
const positiveCount = positiveWords.filter((word) => lowercase.includes(word)).length;
|
|
416
|
+
const negativeCount = negativeWords.filter((word) => lowercase.includes(word)).length;
|
|
417
|
+
if (positiveCount > 0 && negativeCount > 0) return "mixed";
|
|
418
|
+
if (positiveCount > negativeCount) return "positive";
|
|
419
|
+
if (negativeCount > positiveCount) return "negative";
|
|
420
|
+
return "neutral";
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Truncate array to max length for tracking
|
|
424
|
+
*/
|
|
425
|
+
function truncateArray(arr, maxLength = 10) {
|
|
426
|
+
return arr.slice(0, maxLength);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Safe JSON stringify for complex objects
|
|
430
|
+
*/
|
|
431
|
+
function safeStringify(obj, maxLength = 1e3) {
|
|
432
|
+
try {
|
|
433
|
+
if (obj === void 0) return "{}";
|
|
434
|
+
const str = JSON.stringify(obj);
|
|
435
|
+
return str.length > maxLength ? `${str.slice(0, Math.max(0, maxLength))}...` : str;
|
|
436
|
+
} catch {
|
|
437
|
+
return "[Unable to stringify]";
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Calculate conversation quality score
|
|
442
|
+
*/
|
|
443
|
+
function calculateQualityScore(metrics) {
|
|
444
|
+
let score = 100;
|
|
445
|
+
if (metrics.message_count < 3) score -= 20;
|
|
446
|
+
if (metrics.avg_response_time_ms && metrics.avg_response_time_ms > 3e3) score -= 10;
|
|
447
|
+
if (metrics.misunderstanding_count) score -= metrics.misunderstanding_count * 5;
|
|
448
|
+
if (metrics.clarification_count && metrics.clarification_count > 2) score -= (metrics.clarification_count - 2) * 3;
|
|
449
|
+
if (metrics.satisfaction_score && metrics.satisfaction_score >= 4) score += 10;
|
|
450
|
+
return Math.max(0, Math.min(100, score));
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Detect if message needs clarification
|
|
454
|
+
*/
|
|
455
|
+
function needsClarification(message) {
|
|
456
|
+
const lowercase = message.toLowerCase();
|
|
457
|
+
return [
|
|
458
|
+
"it",
|
|
459
|
+
"that one",
|
|
460
|
+
"this",
|
|
461
|
+
"them",
|
|
462
|
+
"those",
|
|
463
|
+
"something like",
|
|
464
|
+
"kind of",
|
|
465
|
+
"sort of",
|
|
466
|
+
"maybe",
|
|
467
|
+
"not sure"
|
|
468
|
+
].some((pattern) => lowercase.includes(pattern));
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Extract product mentions from message
|
|
472
|
+
*/
|
|
473
|
+
function extractProductMentions(message) {
|
|
474
|
+
const mentions = [];
|
|
475
|
+
const categories = [
|
|
476
|
+
"laptop",
|
|
477
|
+
"phone",
|
|
478
|
+
"tablet",
|
|
479
|
+
"watch",
|
|
480
|
+
"headphones",
|
|
481
|
+
"shoes",
|
|
482
|
+
"shirt",
|
|
483
|
+
"pants",
|
|
484
|
+
"dress",
|
|
485
|
+
"jacket"
|
|
486
|
+
];
|
|
487
|
+
const lowercase = message.toLowerCase();
|
|
488
|
+
for (const category of categories) if (lowercase.includes(category)) mentions.push(category);
|
|
489
|
+
return mentions;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Alias for detectIntent for chatbot-specific contexts
|
|
493
|
+
*/
|
|
494
|
+
const detectChatbotIntent = detectIntent;
|
|
495
|
+
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/shared/emitters/ai/track-ai.ts
|
|
498
|
+
/**
|
|
499
|
+
* @fileoverview AI tracking wrapper that integrates with the core emitter system
|
|
500
|
+
* AI tracking wrapper that integrates with the core emitter system
|
|
501
|
+
*/
|
|
502
|
+
/**
|
|
503
|
+
* Convert an AI event specification to a track payload
|
|
504
|
+
*
|
|
505
|
+
* @param eventSpec - The AI event specification
|
|
506
|
+
* @param options - Optional emitter options
|
|
507
|
+
* @returns Track payload ready to be sent to analytics providers
|
|
508
|
+
*/
|
|
509
|
+
function trackAI(eventSpec, options) {
|
|
510
|
+
const enrichedOptions = {
|
|
511
|
+
...options,
|
|
512
|
+
context: {
|
|
513
|
+
...options?.context,
|
|
514
|
+
...eventSpec.category && { traits: {
|
|
515
|
+
...options?.context?.traits,
|
|
516
|
+
event_category: eventSpec.category
|
|
517
|
+
} }
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
return track(eventSpec.name, eventSpec.properties, enrichedOptions);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Helper to create a tracking function for a specific AI event
|
|
524
|
+
* This allows for cleaner usage in applications
|
|
525
|
+
*/
|
|
526
|
+
function createAITracker(eventFactory) {
|
|
527
|
+
return (properties, options) => {
|
|
528
|
+
return trackAI(eventFactory(properties), options);
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/shared/emitters/ai/track-ai-sdk.ts
|
|
534
|
+
/**
|
|
535
|
+
* @fileoverview AI SDK v6 tracking wrapper that integrates with the core emitter system
|
|
536
|
+
* AI SDK v6 tracking wrapper that integrates with the core emitter system
|
|
537
|
+
*
|
|
538
|
+
* Provides tracking for AI SDK v6 operations including:
|
|
539
|
+
* - Agent execution
|
|
540
|
+
* - Completions and text generation
|
|
541
|
+
* - Tool calls and function calling
|
|
542
|
+
* - Streaming responses
|
|
543
|
+
* - Chat sessions
|
|
544
|
+
* - E-commerce chatbot interactions
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* Convert an AI SDK event specification to a track payload
|
|
548
|
+
*
|
|
549
|
+
* @param eventSpec - The AI SDK event specification
|
|
550
|
+
* @param options - Optional emitter options
|
|
551
|
+
* @returns Track payload ready to be sent to analytics providers
|
|
552
|
+
*/
|
|
553
|
+
function trackAISDK(eventSpec, options) {
|
|
554
|
+
const enrichedOptions = {
|
|
555
|
+
...options,
|
|
556
|
+
context: {
|
|
557
|
+
...options?.context,
|
|
558
|
+
traits: {
|
|
559
|
+
...options?.context?.traits,
|
|
560
|
+
event_category: eventSpec.category
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
return track(eventSpec.name, eventSpec.properties, enrichedOptions);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Helper to create a tracking function for a specific AI SDK event
|
|
568
|
+
* This allows for cleaner usage in applications
|
|
569
|
+
*
|
|
570
|
+
* @param eventFactory - Function that creates an event spec from properties
|
|
571
|
+
* @returns Tracking function for the specific event
|
|
572
|
+
*/
|
|
573
|
+
function createAISDKTracker(eventFactory) {
|
|
574
|
+
return (properties, options) => {
|
|
575
|
+
return trackAISDK(eventFactory(properties), options);
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/shared/emitters/ai/events/conversation.ts
|
|
581
|
+
/**
|
|
582
|
+
* @fileoverview Conversation & Messaging Events
|
|
583
|
+
* Conversation & Messaging Events
|
|
584
|
+
*
|
|
585
|
+
* Core conversation lifecycle and message management for ChatGPT-style products.
|
|
586
|
+
* Includes conversation start/end, messaging, regeneration, branching, and streaming.
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* Track conversation start
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* ai.CONVERSATION_STARTED({
|
|
594
|
+
* conversation_id: 'conv_123',
|
|
595
|
+
* model_id: 'claude-3-5-sonnet',
|
|
596
|
+
* conversation_type: 'chat',
|
|
597
|
+
* });
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
const CONVERSATION_STARTED = createAITracker((properties) => ({
|
|
601
|
+
name: AI_EVENTS.CONVERSATION_STARTED,
|
|
602
|
+
category: "conversation",
|
|
603
|
+
properties,
|
|
604
|
+
requiredProperties: []
|
|
605
|
+
}));
|
|
606
|
+
/**
|
|
607
|
+
* Track conversation resume
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* ai.CONVERSATION_RESUMED({
|
|
612
|
+
* conversation_id: 'conv_123',
|
|
613
|
+
* model_id: 'gpt-4',
|
|
614
|
+
* last_active_timestamp: '2024-01-15T10:30:00Z',
|
|
615
|
+
* message_count: 15,
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
const CONVERSATION_RESUMED = createAITracker((properties) => ({
|
|
620
|
+
name: AI_EVENTS.CONVERSATION_RESUMED,
|
|
621
|
+
category: "conversation",
|
|
622
|
+
properties,
|
|
623
|
+
requiredProperties: []
|
|
624
|
+
}));
|
|
625
|
+
/**
|
|
626
|
+
* Track conversation end
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* ai.CONVERSATION_ENDED({
|
|
631
|
+
* conversation_id: 'conv_123',
|
|
632
|
+
* model_id: 'claude-3-5-sonnet',
|
|
633
|
+
* end_reason: 'user-ended',
|
|
634
|
+
* duration_ms: 180000,
|
|
635
|
+
* message_count: 25,
|
|
636
|
+
* });
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
const CONVERSATION_ENDED = createAITracker((properties) => ({
|
|
640
|
+
name: AI_EVENTS.CONVERSATION_ENDED,
|
|
641
|
+
category: "conversation",
|
|
642
|
+
properties,
|
|
643
|
+
requiredProperties: []
|
|
644
|
+
}));
|
|
645
|
+
/**
|
|
646
|
+
* Track user message sent
|
|
647
|
+
*
|
|
648
|
+
* @example
|
|
649
|
+
* ```typescript
|
|
650
|
+
* ai.MESSAGE_SENT({
|
|
651
|
+
* conversation_id: 'conv_123',
|
|
652
|
+
* message_id: 'msg_456',
|
|
653
|
+
* model_id: 'gpt-4',
|
|
654
|
+
* message_role: 'user',
|
|
655
|
+
* message_length: 50,
|
|
656
|
+
* });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
const MESSAGE_SENT = createAITracker((properties) => ({
|
|
660
|
+
name: AI_EVENTS.MESSAGE_SENT,
|
|
661
|
+
category: "conversation",
|
|
662
|
+
properties,
|
|
663
|
+
requiredProperties: ["message_role"]
|
|
664
|
+
}));
|
|
665
|
+
/**
|
|
666
|
+
* Track AI message received
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* ai.MESSAGE_RECEIVED({
|
|
671
|
+
* conversation_id: 'conv_123',
|
|
672
|
+
* message_id: 'msg_457',
|
|
673
|
+
* model_id: 'claude-3-5-sonnet',
|
|
674
|
+
* message_role: 'assistant',
|
|
675
|
+
* message_length: 250,
|
|
676
|
+
* response_time_ms: 850,
|
|
677
|
+
* finish_reason: 'stop',
|
|
678
|
+
* input_tokens: 450,
|
|
679
|
+
* output_tokens: 320,
|
|
680
|
+
* });
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
const MESSAGE_RECEIVED = createAITracker((properties) => ({
|
|
684
|
+
name: AI_EVENTS.MESSAGE_RECEIVED,
|
|
685
|
+
category: "conversation",
|
|
686
|
+
properties,
|
|
687
|
+
requiredProperties: ["message_role"]
|
|
688
|
+
}));
|
|
689
|
+
/**
|
|
690
|
+
* Track message regeneration
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```typescript
|
|
694
|
+
* ai.MESSAGE_REGENERATED({
|
|
695
|
+
* conversation_id: 'conv_123',
|
|
696
|
+
* model_id: 'gpt-4',
|
|
697
|
+
* original_message_id: 'msg_457',
|
|
698
|
+
* attempt_number: 2,
|
|
699
|
+
* reason: 'user-requested',
|
|
700
|
+
* temperature_adjusted: true,
|
|
701
|
+
* });
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
const MESSAGE_REGENERATED = createAITracker((properties) => ({
|
|
705
|
+
name: AI_EVENTS.MESSAGE_REGENERATED,
|
|
706
|
+
category: "conversation",
|
|
707
|
+
properties,
|
|
708
|
+
requiredProperties: ["original_message_id"]
|
|
709
|
+
}));
|
|
710
|
+
/**
|
|
711
|
+
* Track message edit
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```typescript
|
|
715
|
+
* ai.MESSAGE_EDITED({
|
|
716
|
+
* conversation_id: 'conv_123',
|
|
717
|
+
* message_id: 'msg_456',
|
|
718
|
+
* model_id: 'claude-3-5-sonnet',
|
|
719
|
+
* edit_type: 'user-edit',
|
|
720
|
+
* original_length: 50,
|
|
721
|
+
* new_length: 75,
|
|
722
|
+
* });
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
const MESSAGE_EDITED = createAITracker((properties) => ({
|
|
726
|
+
name: AI_EVENTS.MESSAGE_EDITED,
|
|
727
|
+
category: "conversation",
|
|
728
|
+
properties,
|
|
729
|
+
requiredProperties: ["message_role"]
|
|
730
|
+
}));
|
|
731
|
+
/**
|
|
732
|
+
* Track message deletion
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```typescript
|
|
736
|
+
* ai.MESSAGE_DELETED({
|
|
737
|
+
* conversation_id: 'conv_123',
|
|
738
|
+
* message_id: 'msg_458',
|
|
739
|
+
* model_id: 'gpt-4',
|
|
740
|
+
* message_role: 'assistant',
|
|
741
|
+
* deleted_by: 'user',
|
|
742
|
+
* });
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
const MESSAGE_DELETED = createAITracker((properties) => ({
|
|
746
|
+
name: AI_EVENTS.MESSAGE_DELETED,
|
|
747
|
+
category: "conversation",
|
|
748
|
+
properties,
|
|
749
|
+
requiredProperties: ["message_role"]
|
|
750
|
+
}));
|
|
751
|
+
/**
|
|
752
|
+
* Track conversation branch creation
|
|
753
|
+
*
|
|
754
|
+
* @example
|
|
755
|
+
* ```typescript
|
|
756
|
+
* ai.BRANCH_CREATED({
|
|
757
|
+
* conversation_id: 'conv_123',
|
|
758
|
+
* model_id: 'gpt-4',
|
|
759
|
+
* branch_point_message_id: 'msg_457',
|
|
760
|
+
* original_conversation_id: 'conv_123',
|
|
761
|
+
* new_conversation_id: 'conv_124',
|
|
762
|
+
* reason: 'explore-alternative',
|
|
763
|
+
* });
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
const BRANCH_CREATED = createAITracker((properties) => ({
|
|
767
|
+
name: AI_EVENTS.BRANCH_CREATED,
|
|
768
|
+
category: "conversation",
|
|
769
|
+
properties,
|
|
770
|
+
requiredProperties: [
|
|
771
|
+
"branch_point_message_id",
|
|
772
|
+
"new_conversation_id",
|
|
773
|
+
"original_conversation_id"
|
|
774
|
+
]
|
|
775
|
+
}));
|
|
776
|
+
/**
|
|
777
|
+
* Track conversation branch merge
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* ```typescript
|
|
781
|
+
* ai.BRANCH_MERGED({
|
|
782
|
+
* conversation_id: 'conv_123',
|
|
783
|
+
* model_id: 'claude-3-5-sonnet',
|
|
784
|
+
* branch_point_message_id: 'msg_457',
|
|
785
|
+
* original_conversation_id: 'conv_123',
|
|
786
|
+
* new_conversation_id: 'conv_124',
|
|
787
|
+
* merge_strategy: 'keep-both',
|
|
788
|
+
* });
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
const BRANCH_MERGED = createAITracker((properties) => ({
|
|
792
|
+
name: AI_EVENTS.BRANCH_MERGED,
|
|
793
|
+
category: "conversation",
|
|
794
|
+
properties,
|
|
795
|
+
requiredProperties: [
|
|
796
|
+
"branch_point_message_id",
|
|
797
|
+
"new_conversation_id",
|
|
798
|
+
"original_conversation_id"
|
|
799
|
+
]
|
|
800
|
+
}));
|
|
801
|
+
/**
|
|
802
|
+
* Track stop generation (user interrupts response)
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```typescript
|
|
806
|
+
* ai.STOP_GENERATION({
|
|
807
|
+
* conversation_id: 'conv_123',
|
|
808
|
+
* message_id: 'msg_458',
|
|
809
|
+
* model_id: 'gpt-4',
|
|
810
|
+
* partial_length: 120,
|
|
811
|
+
* stop_reason: 'user-interrupted',
|
|
812
|
+
* tokens_used_at_stop: 150,
|
|
813
|
+
* });
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
const STOP_GENERATION = createAITracker((properties) => ({
|
|
817
|
+
name: AI_EVENTS.STOP_GENERATION,
|
|
818
|
+
category: "conversation",
|
|
819
|
+
properties,
|
|
820
|
+
requiredProperties: []
|
|
821
|
+
}));
|
|
822
|
+
/**
|
|
823
|
+
* Track streaming start
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
826
|
+
* ```typescript
|
|
827
|
+
* ai.STREAMING_STARTED({
|
|
828
|
+
* conversation_id: 'conv_123',
|
|
829
|
+
* message_id: 'msg_459',
|
|
830
|
+
* model_id: 'claude-3-5-sonnet',
|
|
831
|
+
* stream_type: 'text',
|
|
832
|
+
* });
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
835
|
+
const STREAMING_STARTED = createAITracker((properties) => ({
|
|
836
|
+
name: AI_EVENTS.STREAMING_STARTED,
|
|
837
|
+
category: "conversation",
|
|
838
|
+
properties,
|
|
839
|
+
requiredProperties: []
|
|
840
|
+
}));
|
|
841
|
+
/**
|
|
842
|
+
* Track streaming chunk received (sample, not every chunk)
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```typescript
|
|
846
|
+
* // Sample every 10th chunk
|
|
847
|
+
* if (chunkCount % 10 === 0) {
|
|
848
|
+
* ai.STREAMING_CHUNK_RECEIVED({
|
|
849
|
+
* conversation_id: 'conv_123',
|
|
850
|
+
* message_id: 'msg_459',
|
|
851
|
+
* model_id: 'gpt-4',
|
|
852
|
+
* stream_type: 'text',
|
|
853
|
+
* chunk_index: chunkCount,
|
|
854
|
+
* chunk_size_bytes: 256,
|
|
855
|
+
* });
|
|
856
|
+
* }
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
859
|
+
const STREAMING_CHUNK_RECEIVED = createAITracker((properties) => ({
|
|
860
|
+
name: AI_EVENTS.STREAMING_CHUNK_RECEIVED,
|
|
861
|
+
category: "conversation",
|
|
862
|
+
properties,
|
|
863
|
+
requiredProperties: []
|
|
864
|
+
}));
|
|
865
|
+
/**
|
|
866
|
+
* Track streaming completion
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```typescript
|
|
870
|
+
* ai.STREAMING_COMPLETED({
|
|
871
|
+
* conversation_id: 'conv_123',
|
|
872
|
+
* message_id: 'msg_459',
|
|
873
|
+
* model_id: 'claude-3-5-sonnet',
|
|
874
|
+
* stream_type: 'text',
|
|
875
|
+
* chunk_count: 45,
|
|
876
|
+
* total_bytes: 11520,
|
|
877
|
+
* stream_duration_ms: 3200,
|
|
878
|
+
* chunks_per_second: 14.06,
|
|
879
|
+
* });
|
|
880
|
+
* ```
|
|
881
|
+
*/
|
|
882
|
+
const STREAMING_COMPLETED = createAITracker((properties) => ({
|
|
883
|
+
name: AI_EVENTS.STREAMING_COMPLETED,
|
|
884
|
+
category: "conversation",
|
|
885
|
+
properties,
|
|
886
|
+
requiredProperties: []
|
|
887
|
+
}));
|
|
888
|
+
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region src/shared/emitters/ai/events/content-generation.ts
|
|
891
|
+
/**
|
|
892
|
+
* @fileoverview Content Generation Events
|
|
893
|
+
* Content Generation Events
|
|
894
|
+
*
|
|
895
|
+
* All types of AI-generated content: code, images, summaries, translations, etc.
|
|
896
|
+
* These track what the AI creates, not what users do with it.
|
|
897
|
+
*/
|
|
898
|
+
/**
|
|
899
|
+
* Track code generation
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```typescript
|
|
903
|
+
* ai.CODE_GENERATED({
|
|
904
|
+
* conversation_id: 'conv_123',
|
|
905
|
+
* model_id: 'gpt-4',
|
|
906
|
+
* language: 'typescript',
|
|
907
|
+
* code_length: 450,
|
|
908
|
+
* code_type: 'function',
|
|
909
|
+
* has_explanation: true,
|
|
910
|
+
* has_tests: false,
|
|
911
|
+
* });
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
const CODE_GENERATED = createAITracker((properties) => ({
|
|
915
|
+
name: AI_EVENTS.CODE_GENERATED,
|
|
916
|
+
category: "content-generation",
|
|
917
|
+
properties,
|
|
918
|
+
requiredProperties: ["task_type"]
|
|
919
|
+
}));
|
|
920
|
+
/**
|
|
921
|
+
* Track code explanation
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* ai.CODE_EXPLAINED({
|
|
926
|
+
* conversation_id: 'conv_123',
|
|
927
|
+
* model_id: 'claude-3-5-sonnet',
|
|
928
|
+
* language: 'python',
|
|
929
|
+
* code_length: 200,
|
|
930
|
+
* explanation_length: 500,
|
|
931
|
+
* explanation_type: 'detailed',
|
|
932
|
+
* });
|
|
933
|
+
* ```
|
|
934
|
+
*/
|
|
935
|
+
const CODE_EXPLAINED = createAITracker((properties) => ({
|
|
936
|
+
name: AI_EVENTS.CODE_EXPLAINED,
|
|
937
|
+
category: "content-generation",
|
|
938
|
+
properties,
|
|
939
|
+
requiredProperties: ["task_type"]
|
|
940
|
+
}));
|
|
941
|
+
/**
|
|
942
|
+
* Track code debugging assistance
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```typescript
|
|
946
|
+
* ai.CODE_DEBUGGED({
|
|
947
|
+
* conversation_id: 'conv_123',
|
|
948
|
+
* model_id: 'gpt-4',
|
|
949
|
+
* language: 'javascript',
|
|
950
|
+
* code_length: 300,
|
|
951
|
+
* issues_found: 3,
|
|
952
|
+
* fixes_suggested: 3,
|
|
953
|
+
* });
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
const CODE_DEBUGGED = createAITracker((properties) => ({
|
|
957
|
+
name: AI_EVENTS.CODE_DEBUGGED,
|
|
958
|
+
category: "content-generation",
|
|
959
|
+
properties,
|
|
960
|
+
requiredProperties: ["task_type"]
|
|
961
|
+
}));
|
|
962
|
+
/**
|
|
963
|
+
* Track code refactoring suggestions
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* ```typescript
|
|
967
|
+
* ai.CODE_REFACTORED({
|
|
968
|
+
* conversation_id: 'conv_123',
|
|
969
|
+
* model_id: 'claude-3-5-sonnet',
|
|
970
|
+
* language: 'typescript',
|
|
971
|
+
* code_length: 500,
|
|
972
|
+
* refactor_type: 'extract-function',
|
|
973
|
+
* improvements_suggested: 5,
|
|
974
|
+
* });
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
const CODE_REFACTORED = createAITracker((properties) => ({
|
|
978
|
+
name: AI_EVENTS.CODE_REFACTORED,
|
|
979
|
+
category: "content-generation",
|
|
980
|
+
properties,
|
|
981
|
+
requiredProperties: ["task_type"]
|
|
982
|
+
}));
|
|
983
|
+
/**
|
|
984
|
+
* Track code translation between languages
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* ai.CODE_TRANSLATED({
|
|
989
|
+
* conversation_id: 'conv_123',
|
|
990
|
+
* model_id: 'gpt-4',
|
|
991
|
+
* language: 'typescript',
|
|
992
|
+
* code_length: 350,
|
|
993
|
+
* source_language: 'python',
|
|
994
|
+
* target_language: 'typescript',
|
|
995
|
+
* });
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
const CODE_TRANSLATED = createAITracker((properties) => ({
|
|
999
|
+
name: AI_EVENTS.CODE_TRANSLATED,
|
|
1000
|
+
category: "content-generation",
|
|
1001
|
+
properties,
|
|
1002
|
+
requiredProperties: ["task_type"]
|
|
1003
|
+
}));
|
|
1004
|
+
/**
|
|
1005
|
+
* Track image generation
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```typescript
|
|
1009
|
+
* ai.IMAGE_GENERATED({
|
|
1010
|
+
* conversation_id: 'conv_123',
|
|
1011
|
+
* model_id: 'dall-e-3',
|
|
1012
|
+
* image_type: 'generated',
|
|
1013
|
+
* prompt_length: 80,
|
|
1014
|
+
* image_format: 'png',
|
|
1015
|
+
* image_size: '1024x1024',
|
|
1016
|
+
* generation_time_ms: 5000,
|
|
1017
|
+
* });
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
const IMAGE_GENERATED = createAITracker((properties) => ({
|
|
1021
|
+
name: AI_EVENTS.IMAGE_GENERATED,
|
|
1022
|
+
category: "content-generation",
|
|
1023
|
+
properties,
|
|
1024
|
+
requiredProperties: []
|
|
1025
|
+
}));
|
|
1026
|
+
/**
|
|
1027
|
+
* Track image editing
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* ai.IMAGE_EDITED({
|
|
1032
|
+
* conversation_id: 'conv_123',
|
|
1033
|
+
* model_id: 'dall-e-3',
|
|
1034
|
+
* image_type: 'edited',
|
|
1035
|
+
* edit_type: 'inpaint',
|
|
1036
|
+
* prompt_length: 50,
|
|
1037
|
+
* image_format: 'png',
|
|
1038
|
+
* });
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
const IMAGE_EDITED = createAITracker((properties) => ({
|
|
1042
|
+
name: AI_EVENTS.IMAGE_EDITED,
|
|
1043
|
+
category: "content-generation",
|
|
1044
|
+
properties,
|
|
1045
|
+
requiredProperties: []
|
|
1046
|
+
}));
|
|
1047
|
+
/**
|
|
1048
|
+
* Track general text generation
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* ai.TEXT_GENERATED({
|
|
1053
|
+
* conversation_id: 'conv_123',
|
|
1054
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1055
|
+
* content_type: 'article',
|
|
1056
|
+
* content_length: 1500,
|
|
1057
|
+
* content_format: 'markdown',
|
|
1058
|
+
* });
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
const TEXT_GENERATED = createAITracker((properties) => ({
|
|
1062
|
+
name: AI_EVENTS.TEXT_GENERATED,
|
|
1063
|
+
category: "content-generation",
|
|
1064
|
+
properties,
|
|
1065
|
+
requiredProperties: []
|
|
1066
|
+
}));
|
|
1067
|
+
/**
|
|
1068
|
+
* Track summary generation
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```typescript
|
|
1072
|
+
* ai.SUMMARY_GENERATED({
|
|
1073
|
+
* conversation_id: 'conv_123',
|
|
1074
|
+
* model_id: 'gpt-4',
|
|
1075
|
+
* source_type: 'document',
|
|
1076
|
+
* source_length: 5000,
|
|
1077
|
+
* summary_length: 300,
|
|
1078
|
+
* summary_type: 'bullet-points',
|
|
1079
|
+
* compression_ratio: 16.7,
|
|
1080
|
+
* });
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
const SUMMARY_GENERATED = createAITracker((properties) => ({
|
|
1084
|
+
name: AI_EVENTS.SUMMARY_GENERATED,
|
|
1085
|
+
category: "content-generation",
|
|
1086
|
+
properties,
|
|
1087
|
+
requiredProperties: [
|
|
1088
|
+
"input_length",
|
|
1089
|
+
"output_length",
|
|
1090
|
+
"summary_type"
|
|
1091
|
+
]
|
|
1092
|
+
}));
|
|
1093
|
+
/**
|
|
1094
|
+
* Track text translation
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* ai.TRANSLATION_GENERATED({
|
|
1099
|
+
* conversation_id: 'conv_123',
|
|
1100
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1101
|
+
* content_type: 'translation',
|
|
1102
|
+
* content_length: 450,
|
|
1103
|
+
* source_language: 'english',
|
|
1104
|
+
* target_language: 'spanish',
|
|
1105
|
+
* });
|
|
1106
|
+
* ```
|
|
1107
|
+
*/
|
|
1108
|
+
const TRANSLATION_GENERATED = createAITracker((properties) => ({
|
|
1109
|
+
name: AI_EVENTS.TRANSLATION_GENERATED,
|
|
1110
|
+
category: "content-generation",
|
|
1111
|
+
properties,
|
|
1112
|
+
requiredProperties: []
|
|
1113
|
+
}));
|
|
1114
|
+
/**
|
|
1115
|
+
* Track text completion
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* ```typescript
|
|
1119
|
+
* ai.COMPLETION_GENERATED({
|
|
1120
|
+
* conversation_id: 'conv_123',
|
|
1121
|
+
* model_id: 'gpt-4',
|
|
1122
|
+
* content_type: 'completion',
|
|
1123
|
+
* content_length: 200,
|
|
1124
|
+
* completion_type: 'sentence',
|
|
1125
|
+
* });
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
const COMPLETION_GENERATED = createAITracker((properties) => ({
|
|
1129
|
+
name: AI_EVENTS.COMPLETION_GENERATED,
|
|
1130
|
+
category: "content-generation",
|
|
1131
|
+
properties,
|
|
1132
|
+
requiredProperties: []
|
|
1133
|
+
}));
|
|
1134
|
+
/**
|
|
1135
|
+
* Track content rewrite
|
|
1136
|
+
*
|
|
1137
|
+
* @example
|
|
1138
|
+
* ```typescript
|
|
1139
|
+
* ai.REWRITE_GENERATED({
|
|
1140
|
+
* conversation_id: 'conv_123',
|
|
1141
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1142
|
+
* content_type: 'rewrite',
|
|
1143
|
+
* content_length: 350,
|
|
1144
|
+
* original_length: 300,
|
|
1145
|
+
* rewrite_style: 'formal',
|
|
1146
|
+
* });
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
const REWRITE_GENERATED = createAITracker((properties) => ({
|
|
1150
|
+
name: AI_EVENTS.REWRITE_GENERATED,
|
|
1151
|
+
category: "content-generation",
|
|
1152
|
+
properties,
|
|
1153
|
+
requiredProperties: []
|
|
1154
|
+
}));
|
|
1155
|
+
/**
|
|
1156
|
+
* Track email draft assistance
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```typescript
|
|
1160
|
+
* ai.EMAIL_DRAFTED({
|
|
1161
|
+
* conversation_id: 'conv_123',
|
|
1162
|
+
* model_id: 'gpt-4',
|
|
1163
|
+
* content_type: 'email',
|
|
1164
|
+
* content_length: 400,
|
|
1165
|
+
* email_type: 'professional',
|
|
1166
|
+
* has_subject: true,
|
|
1167
|
+
* });
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
const EMAIL_DRAFTED = createAITracker((properties) => ({
|
|
1171
|
+
name: AI_EVENTS.EMAIL_DRAFTED,
|
|
1172
|
+
category: "content-generation",
|
|
1173
|
+
properties,
|
|
1174
|
+
requiredProperties: []
|
|
1175
|
+
}));
|
|
1176
|
+
/**
|
|
1177
|
+
* Track document creation
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* ```typescript
|
|
1181
|
+
* ai.DOCUMENT_CREATED({
|
|
1182
|
+
* conversation_id: 'conv_123',
|
|
1183
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1184
|
+
* content_type: 'document',
|
|
1185
|
+
* content_length: 2500,
|
|
1186
|
+
* content_format: 'markdown',
|
|
1187
|
+
* document_type: 'report',
|
|
1188
|
+
* });
|
|
1189
|
+
* ```
|
|
1190
|
+
*/
|
|
1191
|
+
const DOCUMENT_CREATED = createAITracker((properties) => ({
|
|
1192
|
+
name: AI_EVENTS.DOCUMENT_CREATED,
|
|
1193
|
+
category: "content-generation",
|
|
1194
|
+
properties,
|
|
1195
|
+
requiredProperties: []
|
|
1196
|
+
}));
|
|
1197
|
+
/**
|
|
1198
|
+
* Track outline creation
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* ai.OUTLINE_CREATED({
|
|
1203
|
+
* conversation_id: 'conv_123',
|
|
1204
|
+
* model_id: 'gpt-4',
|
|
1205
|
+
* content_type: 'outline',
|
|
1206
|
+
* content_length: 600,
|
|
1207
|
+
* section_count: 8,
|
|
1208
|
+
* outline_depth: 3,
|
|
1209
|
+
* });
|
|
1210
|
+
* ```
|
|
1211
|
+
*/
|
|
1212
|
+
const OUTLINE_CREATED = createAITracker((properties) => ({
|
|
1213
|
+
name: AI_EVENTS.OUTLINE_CREATED,
|
|
1214
|
+
category: "content-generation",
|
|
1215
|
+
properties,
|
|
1216
|
+
requiredProperties: []
|
|
1217
|
+
}));
|
|
1218
|
+
|
|
1219
|
+
//#endregion
|
|
1220
|
+
//#region src/shared/emitters/ai/events/artifacts.ts
|
|
1221
|
+
/**
|
|
1222
|
+
* @fileoverview Artifacts & Canvas Events
|
|
1223
|
+
* Artifacts & Canvas Events
|
|
1224
|
+
*
|
|
1225
|
+
* Interactive artifacts and canvas mode features (Claude-style).
|
|
1226
|
+
* Track creation, editing, execution, and interaction with artifacts.
|
|
1227
|
+
*/
|
|
1228
|
+
/**
|
|
1229
|
+
* Track artifact creation
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```typescript
|
|
1233
|
+
* ai.ARTIFACT_CREATED({
|
|
1234
|
+
* conversation_id: 'conv_123',
|
|
1235
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1236
|
+
* artifact_id: 'art_001',
|
|
1237
|
+
* artifact_type: 'react-component',
|
|
1238
|
+
* action: 'create',
|
|
1239
|
+
* language: 'tsx',
|
|
1240
|
+
* content_length: 850,
|
|
1241
|
+
* });
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
const ARTIFACT_CREATED = createAITracker((properties) => ({
|
|
1245
|
+
name: AI_EVENTS.ARTIFACT_CREATED,
|
|
1246
|
+
category: "artifacts",
|
|
1247
|
+
properties,
|
|
1248
|
+
requiredProperties: ["action", "artifact_type"]
|
|
1249
|
+
}));
|
|
1250
|
+
/**
|
|
1251
|
+
* Track artifact editing
|
|
1252
|
+
*
|
|
1253
|
+
* @example
|
|
1254
|
+
* ```typescript
|
|
1255
|
+
* ai.ARTIFACT_EDITED({
|
|
1256
|
+
* conversation_id: 'conv_123',
|
|
1257
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1258
|
+
* artifact_id: 'art_001',
|
|
1259
|
+
* artifact_type: 'react-component',
|
|
1260
|
+
* action: 'edit',
|
|
1261
|
+
* version: 2,
|
|
1262
|
+
* changes_description: 'Updated button styling',
|
|
1263
|
+
* });
|
|
1264
|
+
* ```
|
|
1265
|
+
*/
|
|
1266
|
+
const ARTIFACT_EDITED = createAITracker((properties) => ({
|
|
1267
|
+
name: AI_EVENTS.ARTIFACT_EDITED,
|
|
1268
|
+
category: "artifacts",
|
|
1269
|
+
properties,
|
|
1270
|
+
requiredProperties: ["action", "artifact_type"]
|
|
1271
|
+
}));
|
|
1272
|
+
/**
|
|
1273
|
+
* Track artifact execution
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```typescript
|
|
1277
|
+
* ai.ARTIFACT_EXECUTED({
|
|
1278
|
+
* conversation_id: 'conv_123',
|
|
1279
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1280
|
+
* artifact_id: 'art_001',
|
|
1281
|
+
* artifact_type: 'code',
|
|
1282
|
+
* action: 'execute',
|
|
1283
|
+
* execution_status: 'success',
|
|
1284
|
+
* execution_time_ms: 150,
|
|
1285
|
+
* });
|
|
1286
|
+
* ```
|
|
1287
|
+
*/
|
|
1288
|
+
const ARTIFACT_EXECUTED = createAITracker((properties) => ({
|
|
1289
|
+
name: AI_EVENTS.ARTIFACT_EXECUTED,
|
|
1290
|
+
category: "artifacts",
|
|
1291
|
+
properties,
|
|
1292
|
+
requiredProperties: ["action", "artifact_type"]
|
|
1293
|
+
}));
|
|
1294
|
+
/**
|
|
1295
|
+
* Track artifact publishing
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* ai.ARTIFACT_PUBLISHED({
|
|
1300
|
+
* conversation_id: 'conv_123',
|
|
1301
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1302
|
+
* artifact_id: 'art_001',
|
|
1303
|
+
* artifact_type: 'visualization',
|
|
1304
|
+
* action: 'publish',
|
|
1305
|
+
* visibility: 'public',
|
|
1306
|
+
* publish_platform: 'web',
|
|
1307
|
+
* });
|
|
1308
|
+
* ```
|
|
1309
|
+
*/
|
|
1310
|
+
const ARTIFACT_PUBLISHED = createAITracker((properties) => ({
|
|
1311
|
+
name: AI_EVENTS.ARTIFACT_PUBLISHED,
|
|
1312
|
+
category: "artifacts",
|
|
1313
|
+
properties,
|
|
1314
|
+
requiredProperties: ["action", "artifact_type"]
|
|
1315
|
+
}));
|
|
1316
|
+
/**
|
|
1317
|
+
* Track artifact forking
|
|
1318
|
+
*
|
|
1319
|
+
* @example
|
|
1320
|
+
* ```typescript
|
|
1321
|
+
* ai.ARTIFACT_FORKED({
|
|
1322
|
+
* conversation_id: 'conv_123',
|
|
1323
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1324
|
+
* artifact_id: 'art_001',
|
|
1325
|
+
* artifact_type: 'react-component',
|
|
1326
|
+
* action: 'fork',
|
|
1327
|
+
* new_artifact_id: 'art_002',
|
|
1328
|
+
* fork_reason: 'experiment',
|
|
1329
|
+
* });
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
const ARTIFACT_FORKED = createAITracker((properties) => ({
|
|
1333
|
+
name: AI_EVENTS.ARTIFACT_FORKED,
|
|
1334
|
+
category: "artifacts",
|
|
1335
|
+
properties,
|
|
1336
|
+
requiredProperties: ["action", "artifact_type"]
|
|
1337
|
+
}));
|
|
1338
|
+
/**
|
|
1339
|
+
* Track canvas mode opened
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* ```typescript
|
|
1343
|
+
* ai.CANVAS_OPENED({
|
|
1344
|
+
* conversation_id: 'conv_123',
|
|
1345
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1346
|
+
* canvas_type: 'code',
|
|
1347
|
+
* initial_content_length: 500,
|
|
1348
|
+
* canvas_size: 'full-screen',
|
|
1349
|
+
* });
|
|
1350
|
+
* ```
|
|
1351
|
+
*/
|
|
1352
|
+
const CANVAS_OPENED = createAITracker((properties) => ({
|
|
1353
|
+
name: AI_EVENTS.CANVAS_OPENED,
|
|
1354
|
+
category: "artifacts",
|
|
1355
|
+
properties,
|
|
1356
|
+
requiredProperties: ["action"]
|
|
1357
|
+
}));
|
|
1358
|
+
/**
|
|
1359
|
+
* Track live preview toggle
|
|
1360
|
+
*
|
|
1361
|
+
* @example
|
|
1362
|
+
* ```typescript
|
|
1363
|
+
* ai.LIVE_PREVIEW_TOGGLED({
|
|
1364
|
+
* conversation_id: 'conv_123',
|
|
1365
|
+
* model_id: 'claude-3-5-net',
|
|
1366
|
+
* artifact_id: 'art_001',
|
|
1367
|
+
* preview_enabled: true,
|
|
1368
|
+
* preview_type: 'browser',
|
|
1369
|
+
* });
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
const LIVE_PREVIEW_TOGGLED = createAITracker((properties) => ({
|
|
1373
|
+
name: AI_EVENTS.LIVE_PREVIEW_TOGGLED,
|
|
1374
|
+
category: "artifacts",
|
|
1375
|
+
properties,
|
|
1376
|
+
requiredProperties: ["action"]
|
|
1377
|
+
}));
|
|
1378
|
+
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region src/shared/emitters/ai/events/product-features.ts
|
|
1381
|
+
/**
|
|
1382
|
+
* @fileoverview Additional AI Product Features
|
|
1383
|
+
* Additional AI Product Features
|
|
1384
|
+
*
|
|
1385
|
+
* Comprehensive tracking for all remaining AI product features:
|
|
1386
|
+
* - User interactions (copy, execute, download)
|
|
1387
|
+
* - Files & attachments
|
|
1388
|
+
* - Context & memory management
|
|
1389
|
+
* - Collaboration & sharing
|
|
1390
|
+
* - Workspace & organization
|
|
1391
|
+
* - Feedback & quality
|
|
1392
|
+
* - System & performance
|
|
1393
|
+
* - Tools & functions
|
|
1394
|
+
* - Search & citations
|
|
1395
|
+
*/
|
|
1396
|
+
/**
|
|
1397
|
+
* Track code copy action
|
|
1398
|
+
*
|
|
1399
|
+
* @example
|
|
1400
|
+
* ```typescript
|
|
1401
|
+
* ai.CODE_COPIED({
|
|
1402
|
+
* conversation_id: 'conv_123',
|
|
1403
|
+
* model_id: 'gpt-4',
|
|
1404
|
+
* code_id: 'code_789',
|
|
1405
|
+
* language: 'typescript',
|
|
1406
|
+
* code_length: 450,
|
|
1407
|
+
* });
|
|
1408
|
+
* ```
|
|
1409
|
+
*/
|
|
1410
|
+
const CODE_COPIED = createAITracker((properties) => ({
|
|
1411
|
+
name: AI_EVENTS.CODE_COPIED,
|
|
1412
|
+
category: "user-interactions",
|
|
1413
|
+
properties,
|
|
1414
|
+
requiredProperties: ["task_type"]
|
|
1415
|
+
}));
|
|
1416
|
+
/**
|
|
1417
|
+
* Track code execution
|
|
1418
|
+
*
|
|
1419
|
+
* @example
|
|
1420
|
+
* ```typescript
|
|
1421
|
+
* ai.CODE_EXECUTED({
|
|
1422
|
+
* conversation_id: 'conv_123',
|
|
1423
|
+
* model_id: 'gpt-4',
|
|
1424
|
+
* code_id: 'code_789',
|
|
1425
|
+
* language: 'typescript',
|
|
1426
|
+
* execution_status: 'success',
|
|
1427
|
+
* execution_time_ms: 120,
|
|
1428
|
+
* });
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
const CODE_EXECUTED = createAITracker((properties) => ({
|
|
1432
|
+
name: AI_EVENTS.CODE_EXECUTED,
|
|
1433
|
+
category: "user-interactions",
|
|
1434
|
+
properties,
|
|
1435
|
+
requiredProperties: ["task_type"]
|
|
1436
|
+
}));
|
|
1437
|
+
/**
|
|
1438
|
+
* Track general content copy
|
|
1439
|
+
*
|
|
1440
|
+
* @example
|
|
1441
|
+
* ```typescript
|
|
1442
|
+
* ai.CONTENT_COPIED({
|
|
1443
|
+
* conversation_id: 'conv_123',
|
|
1444
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1445
|
+
* content_id: 'content_456',
|
|
1446
|
+
* content_type: 'text',
|
|
1447
|
+
* content_length: 350,
|
|
1448
|
+
* });
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
const CONTENT_COPIED = createAITracker((properties) => ({
|
|
1452
|
+
name: AI_EVENTS.CONTENT_COPIED,
|
|
1453
|
+
category: "user-interactions",
|
|
1454
|
+
properties,
|
|
1455
|
+
requiredProperties: []
|
|
1456
|
+
}));
|
|
1457
|
+
/**
|
|
1458
|
+
* Track content download
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* ```typescript
|
|
1462
|
+
* ai.CONTENT_DOWNLOADED({
|
|
1463
|
+
* conversation_id: 'conv_123',
|
|
1464
|
+
* model_id: 'gpt-4',
|
|
1465
|
+
* content_id: 'content_456',
|
|
1466
|
+
* content_type: 'document',
|
|
1467
|
+
* file_format: 'pdf',
|
|
1468
|
+
* file_size_bytes: 1024000,
|
|
1469
|
+
* });
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
const CONTENT_DOWNLOADED = createAITracker((properties) => ({
|
|
1473
|
+
name: AI_EVENTS.CONTENT_DOWNLOADED,
|
|
1474
|
+
category: "user-interactions",
|
|
1475
|
+
properties,
|
|
1476
|
+
requiredProperties: []
|
|
1477
|
+
}));
|
|
1478
|
+
/**
|
|
1479
|
+
* Track content sharing
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* ai.CONTENT_SHARED({
|
|
1484
|
+
* conversation_id: 'conv_123',
|
|
1485
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1486
|
+
* content_id: 'content_456',
|
|
1487
|
+
* content_type: 'code',
|
|
1488
|
+
* share_platform: 'twitter',
|
|
1489
|
+
* });
|
|
1490
|
+
* ```
|
|
1491
|
+
*/
|
|
1492
|
+
const CONTENT_SHARED = createAITracker((properties) => ({
|
|
1493
|
+
name: AI_EVENTS.CONTENT_SHARED,
|
|
1494
|
+
category: "user-interactions",
|
|
1495
|
+
properties,
|
|
1496
|
+
requiredProperties: []
|
|
1497
|
+
}));
|
|
1498
|
+
/**
|
|
1499
|
+
* Track AI suggestion acceptance
|
|
1500
|
+
*
|
|
1501
|
+
* @example
|
|
1502
|
+
* ```typescript
|
|
1503
|
+
* ai.SUGGESTION_ACCEPTED({
|
|
1504
|
+
* conversation_id: 'conv_123',
|
|
1505
|
+
* model_id: 'gpt-4',
|
|
1506
|
+
* suggestion_type: 'code-completion',
|
|
1507
|
+
* suggestion_id: 'sug_123',
|
|
1508
|
+
* });
|
|
1509
|
+
* ```
|
|
1510
|
+
*/
|
|
1511
|
+
const SUGGESTION_ACCEPTED = createAITracker((properties) => ({
|
|
1512
|
+
name: AI_EVENTS.SUGGESTION_ACCEPTED,
|
|
1513
|
+
category: "user-interactions",
|
|
1514
|
+
properties,
|
|
1515
|
+
requiredProperties: []
|
|
1516
|
+
}));
|
|
1517
|
+
/**
|
|
1518
|
+
* Track AI suggestion rejection
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
* ```typescript
|
|
1522
|
+
* ai.SUGGESTION_REJECTED({
|
|
1523
|
+
* conversation_id: 'conv_123',
|
|
1524
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1525
|
+
* suggestion_type: 'text-completion',
|
|
1526
|
+
* suggestion_id: 'sug_124',
|
|
1527
|
+
* rejection_reason: 'not-relevant',
|
|
1528
|
+
* });
|
|
1529
|
+
* ```
|
|
1530
|
+
*/
|
|
1531
|
+
const SUGGESTION_REJECTED = createAITracker((properties) => ({
|
|
1532
|
+
name: AI_EVENTS.SUGGESTION_REJECTED,
|
|
1533
|
+
category: "user-interactions",
|
|
1534
|
+
properties,
|
|
1535
|
+
requiredProperties: []
|
|
1536
|
+
}));
|
|
1537
|
+
/**
|
|
1538
|
+
* Track inline edit applied to AI content
|
|
1539
|
+
*
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```typescript
|
|
1542
|
+
* ai.INLINE_EDIT_APPLIED({
|
|
1543
|
+
* conversation_id: 'conv_123',
|
|
1544
|
+
* model_id: 'gpt-4',
|
|
1545
|
+
* content_id: 'content_456',
|
|
1546
|
+
* edit_type: 'user-refinement',
|
|
1547
|
+
* characters_changed: 25,
|
|
1548
|
+
* });
|
|
1549
|
+
* ```
|
|
1550
|
+
*/
|
|
1551
|
+
const INLINE_EDIT_APPLIED = createAITracker((properties) => ({
|
|
1552
|
+
name: AI_EVENTS.INLINE_EDIT_APPLIED,
|
|
1553
|
+
category: "user-interactions",
|
|
1554
|
+
properties,
|
|
1555
|
+
requiredProperties: []
|
|
1556
|
+
}));
|
|
1557
|
+
/**
|
|
1558
|
+
* Track diff/changes viewed
|
|
1559
|
+
*
|
|
1560
|
+
* @example
|
|
1561
|
+
* ```typescript
|
|
1562
|
+
* ai.DIFF_VIEWED({
|
|
1563
|
+
* conversation_id: 'conv_123',
|
|
1564
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1565
|
+
* content_id: 'content_456',
|
|
1566
|
+
* diff_type: 'side-by-side',
|
|
1567
|
+
* lines_added: 15,
|
|
1568
|
+
* lines_removed: 8,
|
|
1569
|
+
* });
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
const DIFF_VIEWED = createAITracker((properties) => ({
|
|
1573
|
+
name: AI_EVENTS.DIFF_VIEWED,
|
|
1574
|
+
category: "user-interactions",
|
|
1575
|
+
properties,
|
|
1576
|
+
requiredProperties: []
|
|
1577
|
+
}));
|
|
1578
|
+
/**
|
|
1579
|
+
* Track file upload
|
|
1580
|
+
*
|
|
1581
|
+
* @example
|
|
1582
|
+
* ```typescript
|
|
1583
|
+
* ai.FILE_UPLOADED({
|
|
1584
|
+
* conversation_id: 'conv_123',
|
|
1585
|
+
* model_id: 'gpt-4',
|
|
1586
|
+
* file_type: 'pdf',
|
|
1587
|
+
* file_size_bytes: 1024000,
|
|
1588
|
+
* file_count: 1,
|
|
1589
|
+
* });
|
|
1590
|
+
* ```
|
|
1591
|
+
*/
|
|
1592
|
+
const FILE_UPLOADED = createAITracker((properties) => ({
|
|
1593
|
+
name: AI_EVENTS.FILE_UPLOADED,
|
|
1594
|
+
category: "files",
|
|
1595
|
+
properties,
|
|
1596
|
+
requiredProperties: []
|
|
1597
|
+
}));
|
|
1598
|
+
/**
|
|
1599
|
+
* Track file processing completion
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```typescript
|
|
1603
|
+
* ai.FILE_PROCESSED({
|
|
1604
|
+
* conversation_id: 'conv_123',
|
|
1605
|
+
* model_id: 'gpt-4',
|
|
1606
|
+
* file_id: 'file_123',
|
|
1607
|
+
* file_type: 'pdf',
|
|
1608
|
+
* processing_time_ms: 2500,
|
|
1609
|
+
* extracted_text_length: 5000,
|
|
1610
|
+
* processing_status: 'success',
|
|
1611
|
+
* });
|
|
1612
|
+
* ```
|
|
1613
|
+
*/
|
|
1614
|
+
const FILE_PROCESSED = createAITracker((properties) => ({
|
|
1615
|
+
name: AI_EVENTS.FILE_PROCESSED,
|
|
1616
|
+
category: "files",
|
|
1617
|
+
properties,
|
|
1618
|
+
requiredProperties: []
|
|
1619
|
+
}));
|
|
1620
|
+
/**
|
|
1621
|
+
* Track file processing failure
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```typescript
|
|
1625
|
+
* ai.FILE_PROCESSING_FAILED({
|
|
1626
|
+
* conversation_id: 'conv_123',
|
|
1627
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1628
|
+
* file_id: 'file_124',
|
|
1629
|
+
* file_type: 'docx',
|
|
1630
|
+
* processing_status: 'failed',
|
|
1631
|
+
* error_reason: 'unsupported-format',
|
|
1632
|
+
* });
|
|
1633
|
+
* ```
|
|
1634
|
+
*/
|
|
1635
|
+
const FILE_PROCESSING_FAILED = createAITracker((properties) => ({
|
|
1636
|
+
name: AI_EVENTS.FILE_PROCESSING_FAILED,
|
|
1637
|
+
category: "files",
|
|
1638
|
+
properties,
|
|
1639
|
+
requiredProperties: []
|
|
1640
|
+
}));
|
|
1641
|
+
/**
|
|
1642
|
+
* Track file download
|
|
1643
|
+
*
|
|
1644
|
+
* @example
|
|
1645
|
+
* ```typescript
|
|
1646
|
+
* ai.FILE_DOWNLOADED({
|
|
1647
|
+
* conversation_id: 'conv_123',
|
|
1648
|
+
* model_id: 'gpt-4',
|
|
1649
|
+
* file_id: 'file_125',
|
|
1650
|
+
* file_type: 'csv',
|
|
1651
|
+
* file_size_bytes: 512000,
|
|
1652
|
+
* });
|
|
1653
|
+
* ```
|
|
1654
|
+
*/
|
|
1655
|
+
const FILE_DOWNLOADED = createAITracker((properties) => ({
|
|
1656
|
+
name: AI_EVENTS.FILE_DOWNLOADED,
|
|
1657
|
+
category: "files",
|
|
1658
|
+
properties,
|
|
1659
|
+
requiredProperties: []
|
|
1660
|
+
}));
|
|
1661
|
+
/**
|
|
1662
|
+
* Track file reference in conversation
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```typescript
|
|
1666
|
+
* ai.FILE_REFERENCED({
|
|
1667
|
+
* conversation_id: 'conv_123',
|
|
1668
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1669
|
+
* file_id: 'file_123',
|
|
1670
|
+
* file_type: 'pdf',
|
|
1671
|
+
* reference_context: 'answer-question',
|
|
1672
|
+
* });
|
|
1673
|
+
* ```
|
|
1674
|
+
*/
|
|
1675
|
+
const FILE_REFERENCED = createAITracker((properties) => ({
|
|
1676
|
+
name: AI_EVENTS.FILE_REFERENCED,
|
|
1677
|
+
category: "files",
|
|
1678
|
+
properties,
|
|
1679
|
+
requiredProperties: []
|
|
1680
|
+
}));
|
|
1681
|
+
/**
|
|
1682
|
+
* Track file deletion
|
|
1683
|
+
*
|
|
1684
|
+
* @example
|
|
1685
|
+
* ```typescript
|
|
1686
|
+
* ai.FILE_DELETED({
|
|
1687
|
+
* conversation_id: 'conv_123',
|
|
1688
|
+
* model_id: 'gpt-4',
|
|
1689
|
+
* file_id: 'file_126',
|
|
1690
|
+
* file_type: 'image',
|
|
1691
|
+
* deleted_by: 'user',
|
|
1692
|
+
* });
|
|
1693
|
+
* ```
|
|
1694
|
+
*/
|
|
1695
|
+
const FILE_DELETED = createAITracker((properties) => ({
|
|
1696
|
+
name: AI_EVENTS.FILE_DELETED,
|
|
1697
|
+
category: "files",
|
|
1698
|
+
properties,
|
|
1699
|
+
requiredProperties: []
|
|
1700
|
+
}));
|
|
1701
|
+
/**
|
|
1702
|
+
* Track batch file processing
|
|
1703
|
+
*
|
|
1704
|
+
* @example
|
|
1705
|
+
* ```typescript
|
|
1706
|
+
* ai.BATCH_FILES_PROCESSED({
|
|
1707
|
+
* conversation_id: 'conv_123',
|
|
1708
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1709
|
+
* file_count: 5,
|
|
1710
|
+
* total_size_bytes: 5120000,
|
|
1711
|
+
* processing_time_ms: 8500,
|
|
1712
|
+
* processing_status: 'success',
|
|
1713
|
+
* });
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
const BATCH_FILES_PROCESSED = createAITracker((properties) => ({
|
|
1717
|
+
name: AI_EVENTS.BATCH_FILES_PROCESSED,
|
|
1718
|
+
category: "files",
|
|
1719
|
+
properties,
|
|
1720
|
+
requiredProperties: []
|
|
1721
|
+
}));
|
|
1722
|
+
/**
|
|
1723
|
+
* Track context window update
|
|
1724
|
+
*
|
|
1725
|
+
* @example
|
|
1726
|
+
* ```typescript
|
|
1727
|
+
* ai.CONTEXT_WINDOW_UPDATED({
|
|
1728
|
+
* conversation_id: 'conv_123',
|
|
1729
|
+
* model_id: 'gpt-4',
|
|
1730
|
+
* context_size_tokens: 8000,
|
|
1731
|
+
* context_type: 'conversation',
|
|
1732
|
+
* });
|
|
1733
|
+
* ```
|
|
1734
|
+
*/
|
|
1735
|
+
const CONTEXT_WINDOW_UPDATED = createAITracker((properties) => ({
|
|
1736
|
+
name: AI_EVENTS.CONTEXT_WINDOW_UPDATED,
|
|
1737
|
+
category: "context",
|
|
1738
|
+
properties,
|
|
1739
|
+
requiredProperties: ["context_type"]
|
|
1740
|
+
}));
|
|
1741
|
+
/**
|
|
1742
|
+
* Track memory creation
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```typescript
|
|
1746
|
+
* ai.MEMORY_CREATED({
|
|
1747
|
+
* conversation_id: 'conv_123',
|
|
1748
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1749
|
+
* memory_id: 'mem_123',
|
|
1750
|
+
* memory_type: 'user-preference',
|
|
1751
|
+
* memory_content_length: 50,
|
|
1752
|
+
* memory_source: 'explicit',
|
|
1753
|
+
* });
|
|
1754
|
+
* ```
|
|
1755
|
+
*/
|
|
1756
|
+
const MEMORY_CREATED = createAITracker((properties) => ({
|
|
1757
|
+
name: AI_EVENTS.MEMORY_CREATED,
|
|
1758
|
+
category: "context",
|
|
1759
|
+
properties,
|
|
1760
|
+
requiredProperties: ["memory_type"]
|
|
1761
|
+
}));
|
|
1762
|
+
/**
|
|
1763
|
+
* Track memory retrieval
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* ```typescript
|
|
1767
|
+
* ai.MEMORY_RETRIEVED({
|
|
1768
|
+
* conversation_id: 'conv_123',
|
|
1769
|
+
* model_id: 'gpt-4',
|
|
1770
|
+
* memory_id: 'mem_123',
|
|
1771
|
+
* memory_type: 'user-preference',
|
|
1772
|
+
* retrieval_relevance_score: 0.95,
|
|
1773
|
+
* });
|
|
1774
|
+
* ```
|
|
1775
|
+
*/
|
|
1776
|
+
const MEMORY_RETRIEVED = createAITracker((properties) => ({
|
|
1777
|
+
name: AI_EVENTS.MEMORY_RETRIEVED,
|
|
1778
|
+
category: "context",
|
|
1779
|
+
properties,
|
|
1780
|
+
requiredProperties: ["memory_type"]
|
|
1781
|
+
}));
|
|
1782
|
+
/**
|
|
1783
|
+
* Track memory update
|
|
1784
|
+
*
|
|
1785
|
+
* @example
|
|
1786
|
+
* ```typescript
|
|
1787
|
+
* ai.MEMORY_UPDATED({
|
|
1788
|
+
* conversation_id: 'conv_123',
|
|
1789
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1790
|
+
* memory_id: 'mem_123',
|
|
1791
|
+
* memory_type: 'fact',
|
|
1792
|
+
* update_reason: 'correction',
|
|
1793
|
+
* });
|
|
1794
|
+
* ```
|
|
1795
|
+
*/
|
|
1796
|
+
const MEMORY_UPDATED = createAITracker((properties) => ({
|
|
1797
|
+
name: AI_EVENTS.MEMORY_UPDATED,
|
|
1798
|
+
category: "context",
|
|
1799
|
+
properties,
|
|
1800
|
+
requiredProperties: ["memory_type"]
|
|
1801
|
+
}));
|
|
1802
|
+
/**
|
|
1803
|
+
* Track memory deletion
|
|
1804
|
+
*
|
|
1805
|
+
* @example
|
|
1806
|
+
* ```typescript
|
|
1807
|
+
* ai.MEMORY_DELETED({
|
|
1808
|
+
* conversation_id: 'conv_123',
|
|
1809
|
+
* model_id: 'gpt-4',
|
|
1810
|
+
* memory_id: 'mem_124',
|
|
1811
|
+
* memory_type: 'user-preference',
|
|
1812
|
+
* deleted_by: 'user',
|
|
1813
|
+
* });
|
|
1814
|
+
* ```
|
|
1815
|
+
*/
|
|
1816
|
+
const MEMORY_DELETED = createAITracker((properties) => ({
|
|
1817
|
+
name: AI_EVENTS.MEMORY_DELETED,
|
|
1818
|
+
category: "context",
|
|
1819
|
+
properties,
|
|
1820
|
+
requiredProperties: ["memory_type"]
|
|
1821
|
+
}));
|
|
1822
|
+
/**
|
|
1823
|
+
* Track custom instructions update
|
|
1824
|
+
*
|
|
1825
|
+
* @example
|
|
1826
|
+
* ```typescript
|
|
1827
|
+
* ai.CUSTOM_INSTRUCTIONS_UPDATED({
|
|
1828
|
+
* model_id: 'gpt-4',
|
|
1829
|
+
* user_id: 'user_123',
|
|
1830
|
+
* instructions_length: 200,
|
|
1831
|
+
* has_preferences: true,
|
|
1832
|
+
* has_constraints: true,
|
|
1833
|
+
* });
|
|
1834
|
+
* ```
|
|
1835
|
+
*/
|
|
1836
|
+
const CUSTOM_INSTRUCTIONS_UPDATED = createAITracker((properties) => ({
|
|
1837
|
+
name: AI_EVENTS.CUSTOM_INSTRUCTIONS_UPDATED,
|
|
1838
|
+
category: "context",
|
|
1839
|
+
properties,
|
|
1840
|
+
requiredProperties: ["context_type"]
|
|
1841
|
+
}));
|
|
1842
|
+
/**
|
|
1843
|
+
* Track project context loading
|
|
1844
|
+
*
|
|
1845
|
+
* @example
|
|
1846
|
+
* ```typescript
|
|
1847
|
+
* ai.PROJECT_CONTEXT_LOADED({
|
|
1848
|
+
* conversation_id: 'conv_123',
|
|
1849
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1850
|
+
* context_type: 'project',
|
|
1851
|
+
* context_size_tokens: 5000,
|
|
1852
|
+
* project_id: 'proj_456',
|
|
1853
|
+
* });
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
const PROJECT_CONTEXT_LOADED = createAITracker((properties) => ({
|
|
1857
|
+
name: AI_EVENTS.PROJECT_CONTEXT_LOADED,
|
|
1858
|
+
category: "context",
|
|
1859
|
+
properties,
|
|
1860
|
+
requiredProperties: ["context_type"]
|
|
1861
|
+
}));
|
|
1862
|
+
/**
|
|
1863
|
+
* Track RAG query execution
|
|
1864
|
+
*
|
|
1865
|
+
* @example
|
|
1866
|
+
* ```typescript
|
|
1867
|
+
* ai.RAG_QUERY_EXECUTED({
|
|
1868
|
+
* conversation_id: 'conv_123',
|
|
1869
|
+
* model_id: 'gpt-4',
|
|
1870
|
+
* query_text: 'Find documentation about React hooks',
|
|
1871
|
+
* query_embedding_dimensions: 1536,
|
|
1872
|
+
* chunks_retrieved: 5,
|
|
1873
|
+
* retrieval_time_ms: 150,
|
|
1874
|
+
* retrieval_status: 'success',
|
|
1875
|
+
* });
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
const RAG_QUERY_EXECUTED = createAITracker((properties) => ({
|
|
1879
|
+
name: AI_EVENTS.RAG_QUERY_EXECUTED,
|
|
1880
|
+
category: "context",
|
|
1881
|
+
properties,
|
|
1882
|
+
requiredProperties: ["context_type"]
|
|
1883
|
+
}));
|
|
1884
|
+
/**
|
|
1885
|
+
* Track embedding generation
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```typescript
|
|
1889
|
+
* ai.EMBEDDING_GENERATED({
|
|
1890
|
+
* model_id: 'text-embedding-ada-002',
|
|
1891
|
+
* text_length: 500,
|
|
1892
|
+
* embedding_dimensions: 1536,
|
|
1893
|
+
* generation_time_ms: 80,
|
|
1894
|
+
* });
|
|
1895
|
+
* ```
|
|
1896
|
+
*/
|
|
1897
|
+
const EMBEDDING_GENERATED = createAITracker((properties) => ({
|
|
1898
|
+
name: AI_EVENTS.EMBEDDING_GENERATED,
|
|
1899
|
+
category: "context",
|
|
1900
|
+
properties,
|
|
1901
|
+
requiredProperties: ["context_type"]
|
|
1902
|
+
}));
|
|
1903
|
+
/**
|
|
1904
|
+
* Track knowledge base query
|
|
1905
|
+
*
|
|
1906
|
+
* @example
|
|
1907
|
+
* ```typescript
|
|
1908
|
+
* ai.KNOWLEDGE_BASE_QUERIED({
|
|
1909
|
+
* conversation_id: 'conv_123',
|
|
1910
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1911
|
+
* query_text: 'What is our refund policy?',
|
|
1912
|
+
* results_found: 3,
|
|
1913
|
+
* query_time_ms: 120,
|
|
1914
|
+
* });
|
|
1915
|
+
* ```
|
|
1916
|
+
*/
|
|
1917
|
+
const KNOWLEDGE_BASE_QUERIED = createAITracker((properties) => ({
|
|
1918
|
+
name: AI_EVENTS.KNOWLEDGE_BASE_QUERIED,
|
|
1919
|
+
category: "context",
|
|
1920
|
+
properties,
|
|
1921
|
+
requiredProperties: ["context_type"]
|
|
1922
|
+
}));
|
|
1923
|
+
/**
|
|
1924
|
+
* Track conversation sharing
|
|
1925
|
+
*
|
|
1926
|
+
* @example
|
|
1927
|
+
* ```typescript
|
|
1928
|
+
* ai.CONVERSATION_SHARED({
|
|
1929
|
+
* conversation_id: 'conv_123',
|
|
1930
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1931
|
+
* share_type: 'public-link',
|
|
1932
|
+
* share_permissions: 'view-only',
|
|
1933
|
+
* message_count: 15,
|
|
1934
|
+
* });
|
|
1935
|
+
* ```
|
|
1936
|
+
*/
|
|
1937
|
+
const CONVERSATION_SHARED = createAITracker((properties) => ({
|
|
1938
|
+
name: AI_EVENTS.CONVERSATION_SHARED,
|
|
1939
|
+
category: "collaboration",
|
|
1940
|
+
properties,
|
|
1941
|
+
requiredProperties: []
|
|
1942
|
+
}));
|
|
1943
|
+
/**
|
|
1944
|
+
* Track conversation forking
|
|
1945
|
+
*
|
|
1946
|
+
* @example
|
|
1947
|
+
* ```typescript
|
|
1948
|
+
* ai.CONVERSATION_FORKED({
|
|
1949
|
+
* conversation_id: 'conv_123',
|
|
1950
|
+
* model_id: 'gpt-4',
|
|
1951
|
+
* original_conversation_id: 'conv_123',
|
|
1952
|
+
* new_conversation_id: 'conv_125',
|
|
1953
|
+
* forked_from_message_id: 'msg_460',
|
|
1954
|
+
* });
|
|
1955
|
+
* ```
|
|
1956
|
+
*/
|
|
1957
|
+
const CONVERSATION_FORKED = createAITracker((properties) => ({
|
|
1958
|
+
name: AI_EVENTS.CONVERSATION_FORKED,
|
|
1959
|
+
category: "collaboration",
|
|
1960
|
+
properties,
|
|
1961
|
+
requiredProperties: []
|
|
1962
|
+
}));
|
|
1963
|
+
/**
|
|
1964
|
+
* Track workspace creation
|
|
1965
|
+
*
|
|
1966
|
+
* @example
|
|
1967
|
+
* ```typescript
|
|
1968
|
+
* ai.WORKSPACE_CREATED({
|
|
1969
|
+
* workspace_id: 'ws_001',
|
|
1970
|
+
* model_id: 'claude-3-5-sonnet',
|
|
1971
|
+
* workspace_type: 'team',
|
|
1972
|
+
* member_count: 5,
|
|
1973
|
+
* });
|
|
1974
|
+
* ```
|
|
1975
|
+
*/
|
|
1976
|
+
const WORKSPACE_CREATED = createAITracker((properties) => ({
|
|
1977
|
+
name: AI_EVENTS.WORKSPACE_CREATED,
|
|
1978
|
+
category: "collaboration",
|
|
1979
|
+
properties,
|
|
1980
|
+
requiredProperties: ["action"]
|
|
1981
|
+
}));
|
|
1982
|
+
/**
|
|
1983
|
+
* Track member invitation
|
|
1984
|
+
*
|
|
1985
|
+
* @example
|
|
1986
|
+
* ```typescript
|
|
1987
|
+
* ai.MEMBER_INVITED({
|
|
1988
|
+
* workspace_id: 'ws_001',
|
|
1989
|
+
* model_id: 'gpt-4',
|
|
1990
|
+
* invitee_role: 'member',
|
|
1991
|
+
* invitation_method: 'email',
|
|
1992
|
+
* });
|
|
1993
|
+
* ```
|
|
1994
|
+
*/
|
|
1995
|
+
const MEMBER_INVITED = createAITracker((properties) => ({
|
|
1996
|
+
name: AI_EVENTS.MEMBER_INVITED,
|
|
1997
|
+
category: "collaboration",
|
|
1998
|
+
properties,
|
|
1999
|
+
requiredProperties: []
|
|
2000
|
+
}));
|
|
2001
|
+
/**
|
|
2002
|
+
* Track collaboration comment
|
|
2003
|
+
*
|
|
2004
|
+
* @example
|
|
2005
|
+
* ```typescript
|
|
2006
|
+
* ai.COMMENT_ADDED({
|
|
2007
|
+
* conversation_id: 'conv_123',
|
|
2008
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2009
|
+
* comment_target: 'message',
|
|
2010
|
+
* comment_length: 150,
|
|
2011
|
+
* });
|
|
2012
|
+
* ```
|
|
2013
|
+
*/
|
|
2014
|
+
const COMMENT_ADDED = createAITracker((properties) => ({
|
|
2015
|
+
name: AI_EVENTS.COMMENT_ADDED,
|
|
2016
|
+
category: "collaboration",
|
|
2017
|
+
properties,
|
|
2018
|
+
requiredProperties: []
|
|
2019
|
+
}));
|
|
2020
|
+
/**
|
|
2021
|
+
* Track permission change
|
|
2022
|
+
*
|
|
2023
|
+
* @example
|
|
2024
|
+
* ```typescript
|
|
2025
|
+
* ai.PERMISSION_CHANGED({
|
|
2026
|
+
* workspace_id: 'ws_001',
|
|
2027
|
+
* model_id: 'gpt-4',
|
|
2028
|
+
* target_user_id: 'user_456',
|
|
2029
|
+
* old_permission: 'viewer',
|
|
2030
|
+
* new_permission: 'editor',
|
|
2031
|
+
* });
|
|
2032
|
+
* ```
|
|
2033
|
+
*/
|
|
2034
|
+
const PERMISSION_CHANGED = createAITracker((properties) => ({
|
|
2035
|
+
name: AI_EVENTS.PERMISSION_CHANGED,
|
|
2036
|
+
category: "collaboration",
|
|
2037
|
+
properties,
|
|
2038
|
+
requiredProperties: []
|
|
2039
|
+
}));
|
|
2040
|
+
/**
|
|
2041
|
+
* Track conversation rename
|
|
2042
|
+
*
|
|
2043
|
+
* @example
|
|
2044
|
+
* ```typescript
|
|
2045
|
+
* ai.CONVERSATION_RENAMED({
|
|
2046
|
+
* conversation_id: 'conv_123',
|
|
2047
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2048
|
+
* old_title: 'Chat',
|
|
2049
|
+
* new_title: 'React Project Discussion',
|
|
2050
|
+
* });
|
|
2051
|
+
* ```
|
|
2052
|
+
*/
|
|
2053
|
+
const CONVERSATION_RENAMED = createAITracker((properties) => ({
|
|
2054
|
+
name: AI_EVENTS.CONVERSATION_RENAMED,
|
|
2055
|
+
category: "workspace",
|
|
2056
|
+
properties,
|
|
2057
|
+
requiredProperties: ["action"]
|
|
2058
|
+
}));
|
|
2059
|
+
/**
|
|
2060
|
+
* Track conversation archival
|
|
2061
|
+
*
|
|
2062
|
+
* @example
|
|
2063
|
+
* ```typescript
|
|
2064
|
+
* ai.CONVERSATION_ARCHIVED({
|
|
2065
|
+
* conversation_id: 'conv_123',
|
|
2066
|
+
* model_id: 'gpt-4',
|
|
2067
|
+
* archive_reason: 'completed',
|
|
2068
|
+
* });
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
2071
|
+
const CONVERSATION_ARCHIVED = createAITracker((properties) => ({
|
|
2072
|
+
name: AI_EVENTS.CONVERSATION_ARCHIVED,
|
|
2073
|
+
category: "workspace",
|
|
2074
|
+
properties,
|
|
2075
|
+
requiredProperties: ["action"]
|
|
2076
|
+
}));
|
|
2077
|
+
/**
|
|
2078
|
+
* Track conversation deletion
|
|
2079
|
+
*
|
|
2080
|
+
* @example
|
|
2081
|
+
* ```typescript
|
|
2082
|
+
* ai.CONVERSATION_DELETED({
|
|
2083
|
+
* conversation_id: 'conv_124',
|
|
2084
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2085
|
+
* message_count: 8,
|
|
2086
|
+
* deleted_by: 'user',
|
|
2087
|
+
* });
|
|
2088
|
+
* ```
|
|
2089
|
+
*/
|
|
2090
|
+
const CONVERSATION_DELETED = createAITracker((properties) => ({
|
|
2091
|
+
name: AI_EVENTS.CONVERSATION_DELETED,
|
|
2092
|
+
category: "workspace",
|
|
2093
|
+
properties,
|
|
2094
|
+
requiredProperties: ["action"]
|
|
2095
|
+
}));
|
|
2096
|
+
/**
|
|
2097
|
+
* Track folder creation
|
|
2098
|
+
*
|
|
2099
|
+
* @example
|
|
2100
|
+
* ```typescript
|
|
2101
|
+
* ai.FOLDER_CREATED({
|
|
2102
|
+
* workspace_id: 'ws_001',
|
|
2103
|
+
* model_id: 'gpt-4',
|
|
2104
|
+
* folder_name: 'Project Ideas',
|
|
2105
|
+
* parent_folder_id: 'folder_root',
|
|
2106
|
+
* });
|
|
2107
|
+
* ```
|
|
2108
|
+
*/
|
|
2109
|
+
const FOLDER_CREATED = createAITracker((properties) => ({
|
|
2110
|
+
name: AI_EVENTS.FOLDER_CREATED,
|
|
2111
|
+
category: "workspace",
|
|
2112
|
+
properties,
|
|
2113
|
+
requiredProperties: ["action"]
|
|
2114
|
+
}));
|
|
2115
|
+
/**
|
|
2116
|
+
* Track tag addition
|
|
2117
|
+
*
|
|
2118
|
+
* @example
|
|
2119
|
+
* ```typescript
|
|
2120
|
+
* ai.TAG_ADDED({
|
|
2121
|
+
* conversation_id: 'conv_123',
|
|
2122
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2123
|
+
* tag_name: 'important',
|
|
2124
|
+
* tag_category: 'priority',
|
|
2125
|
+
* });
|
|
2126
|
+
* ```
|
|
2127
|
+
*/
|
|
2128
|
+
const TAG_ADDED = createAITracker((properties) => ({
|
|
2129
|
+
name: AI_EVENTS.TAG_ADDED,
|
|
2130
|
+
category: "workspace",
|
|
2131
|
+
properties,
|
|
2132
|
+
requiredProperties: ["action"]
|
|
2133
|
+
}));
|
|
2134
|
+
/**
|
|
2135
|
+
* Track conversation search
|
|
2136
|
+
*
|
|
2137
|
+
* @example
|
|
2138
|
+
* ```typescript
|
|
2139
|
+
* ai.SEARCH_PERFORMED({
|
|
2140
|
+
* model_id: 'gpt-4',
|
|
2141
|
+
* search_query: 'React hooks',
|
|
2142
|
+
* results_found: 12,
|
|
2143
|
+
* search_scope: 'all-conversations',
|
|
2144
|
+
* });
|
|
2145
|
+
* ```
|
|
2146
|
+
*/
|
|
2147
|
+
const SEARCH_PERFORMED = createAITracker((properties) => ({
|
|
2148
|
+
name: AI_EVENTS.SEARCH_PERFORMED,
|
|
2149
|
+
category: "workspace",
|
|
2150
|
+
properties,
|
|
2151
|
+
requiredProperties: ["action"]
|
|
2152
|
+
}));
|
|
2153
|
+
/**
|
|
2154
|
+
* Track filter application
|
|
2155
|
+
*
|
|
2156
|
+
* @example
|
|
2157
|
+
* ```typescript
|
|
2158
|
+
* ai.FILTER_APPLIED({
|
|
2159
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2160
|
+
* filter_type: 'date-range',
|
|
2161
|
+
* filter_value: 'last-7-days',
|
|
2162
|
+
* results_count: 24,
|
|
2163
|
+
* });
|
|
2164
|
+
* ```
|
|
2165
|
+
*/
|
|
2166
|
+
const FILTER_APPLIED = createAITracker((properties) => ({
|
|
2167
|
+
name: AI_EVENTS.FILTER_APPLIED,
|
|
2168
|
+
category: "workspace",
|
|
2169
|
+
properties,
|
|
2170
|
+
requiredProperties: ["action"]
|
|
2171
|
+
}));
|
|
2172
|
+
/**
|
|
2173
|
+
* Track user feedback
|
|
2174
|
+
*
|
|
2175
|
+
* @example
|
|
2176
|
+
* ```typescript
|
|
2177
|
+
* ai.FEEDBACK_PROVIDED({
|
|
2178
|
+
* conversation_id: 'conv_123',
|
|
2179
|
+
* model_id: 'gpt-4',
|
|
2180
|
+
* message_id: 'msg_457',
|
|
2181
|
+
* feedback_type: 'thumbs-up',
|
|
2182
|
+
* feedback_comment_length: 50,
|
|
2183
|
+
* });
|
|
2184
|
+
* ```
|
|
2185
|
+
*/
|
|
2186
|
+
const FEEDBACK_PROVIDED = createAITracker((properties) => ({
|
|
2187
|
+
name: AI_EVENTS.FEEDBACK_PROVIDED,
|
|
2188
|
+
category: "feedback",
|
|
2189
|
+
properties,
|
|
2190
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2191
|
+
}));
|
|
2192
|
+
/**
|
|
2193
|
+
* Track response rating
|
|
2194
|
+
*
|
|
2195
|
+
* @example
|
|
2196
|
+
* ```typescript
|
|
2197
|
+
* ai.RESPONSE_RATED({
|
|
2198
|
+
* conversation_id: 'conv_123',
|
|
2199
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2200
|
+
* message_id: 'msg_458',
|
|
2201
|
+
* rating_value: 5,
|
|
2202
|
+
* rating_scale: '1-5',
|
|
2203
|
+
* });
|
|
2204
|
+
* ```
|
|
2205
|
+
*/
|
|
2206
|
+
const RESPONSE_RATED = createAITracker((properties) => ({
|
|
2207
|
+
name: AI_EVENTS.RESPONSE_RATED,
|
|
2208
|
+
category: "feedback",
|
|
2209
|
+
properties,
|
|
2210
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2211
|
+
}));
|
|
2212
|
+
/**
|
|
2213
|
+
* Track bug report
|
|
2214
|
+
*
|
|
2215
|
+
* @example
|
|
2216
|
+
* ```typescript
|
|
2217
|
+
* ai.BUG_REPORTED({
|
|
2218
|
+
* conversation_id: 'conv_123',
|
|
2219
|
+
* model_id: 'gpt-4',
|
|
2220
|
+
* bug_type: 'incorrect-output',
|
|
2221
|
+
* bug_severity: 'medium',
|
|
2222
|
+
* });
|
|
2223
|
+
* ```
|
|
2224
|
+
*/
|
|
2225
|
+
const BUG_REPORTED = createAITracker((properties) => ({
|
|
2226
|
+
name: AI_EVENTS.BUG_REPORTED,
|
|
2227
|
+
category: "feedback",
|
|
2228
|
+
properties,
|
|
2229
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2230
|
+
}));
|
|
2231
|
+
/**
|
|
2232
|
+
* Track feature request
|
|
2233
|
+
*
|
|
2234
|
+
* @example
|
|
2235
|
+
* ```typescript
|
|
2236
|
+
* ai.FEATURE_REQUESTED({
|
|
2237
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2238
|
+
* feature_category: 'ui',
|
|
2239
|
+
* feature_description_length: 200,
|
|
2240
|
+
* });
|
|
2241
|
+
* ```
|
|
2242
|
+
*/
|
|
2243
|
+
const FEATURE_REQUESTED = createAITracker((properties) => ({
|
|
2244
|
+
name: AI_EVENTS.FEATURE_REQUESTED,
|
|
2245
|
+
category: "feedback",
|
|
2246
|
+
properties,
|
|
2247
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2248
|
+
}));
|
|
2249
|
+
/**
|
|
2250
|
+
* Track harmful content flag
|
|
2251
|
+
*
|
|
2252
|
+
* @example
|
|
2253
|
+
* ```typescript
|
|
2254
|
+
* ai.HARMFUL_CONTENT_FLAGGED({
|
|
2255
|
+
* conversation_id: 'conv_123',
|
|
2256
|
+
* model_id: 'gpt-4',
|
|
2257
|
+
* message_id: 'msg_459',
|
|
2258
|
+
* content_type: 'misinformation',
|
|
2259
|
+
* severity: 'high',
|
|
2260
|
+
* });
|
|
2261
|
+
* ```
|
|
2262
|
+
*/
|
|
2263
|
+
const HARMFUL_CONTENT_FLAGGED = createAITracker((properties) => ({
|
|
2264
|
+
name: AI_EVENTS.HARMFUL_CONTENT_FLAGGED,
|
|
2265
|
+
category: "feedback",
|
|
2266
|
+
properties,
|
|
2267
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2268
|
+
}));
|
|
2269
|
+
/**
|
|
2270
|
+
* Track quality issue report
|
|
2271
|
+
*
|
|
2272
|
+
* @example
|
|
2273
|
+
* ```typescript
|
|
2274
|
+
* ai.QUALITY_ISSUE_REPORTED({
|
|
2275
|
+
* conversation_id: 'conv_123',
|
|
2276
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2277
|
+
* message_id: 'msg_460',
|
|
2278
|
+
* issue_type: 'factual-error',
|
|
2279
|
+
* issue_severity: 'medium',
|
|
2280
|
+
* });
|
|
2281
|
+
* ```
|
|
2282
|
+
*/
|
|
2283
|
+
const QUALITY_ISSUE_REPORTED = createAITracker((properties) => ({
|
|
2284
|
+
name: AI_EVENTS.QUALITY_ISSUE_REPORTED,
|
|
2285
|
+
category: "feedback",
|
|
2286
|
+
properties,
|
|
2287
|
+
requiredProperties: ["feedback_type", "message_id"]
|
|
2288
|
+
}));
|
|
2289
|
+
/**
|
|
2290
|
+
* Track model switch
|
|
2291
|
+
*
|
|
2292
|
+
* @example
|
|
2293
|
+
* ```typescript
|
|
2294
|
+
* ai.MODEL_SWITCHED({
|
|
2295
|
+
* conversation_id: 'conv_123',
|
|
2296
|
+
* model_id: 'gpt-4',
|
|
2297
|
+
* previous_model: 'gpt-3.5-turbo',
|
|
2298
|
+
* switch_reason: 'user-preference',
|
|
2299
|
+
* });
|
|
2300
|
+
* ```
|
|
2301
|
+
*/
|
|
2302
|
+
const MODEL_SWITCHED = createAITracker((properties) => ({
|
|
2303
|
+
name: AI_EVENTS.MODEL_SWITCHED,
|
|
2304
|
+
category: "system",
|
|
2305
|
+
properties,
|
|
2306
|
+
requiredProperties: []
|
|
2307
|
+
}));
|
|
2308
|
+
/**
|
|
2309
|
+
* Track settings update
|
|
2310
|
+
*
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* ai.SETTINGS_UPDATED({
|
|
2314
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2315
|
+
* user_id: 'user_123',
|
|
2316
|
+
* settings_category: 'appearance',
|
|
2317
|
+
* settings_changed: ['theme', 'font-size'],
|
|
2318
|
+
* });
|
|
2319
|
+
* ```
|
|
2320
|
+
*/
|
|
2321
|
+
const SETTINGS_UPDATED = createAITracker((properties) => ({
|
|
2322
|
+
name: AI_EVENTS.SETTINGS_UPDATED,
|
|
2323
|
+
category: "system",
|
|
2324
|
+
properties,
|
|
2325
|
+
requiredProperties: []
|
|
2326
|
+
}));
|
|
2327
|
+
/**
|
|
2328
|
+
* Track error occurrence
|
|
2329
|
+
*
|
|
2330
|
+
* @example
|
|
2331
|
+
* ```typescript
|
|
2332
|
+
* ai.ERROR_OCCURRED({
|
|
2333
|
+
* conversation_id: 'conv_123',
|
|
2334
|
+
* model_id: 'gpt-4',
|
|
2335
|
+
* error_type: 'api-error',
|
|
2336
|
+
* error_code: '500',
|
|
2337
|
+
* error_message: 'Internal server error',
|
|
2338
|
+
* });
|
|
2339
|
+
* ```
|
|
2340
|
+
*/
|
|
2341
|
+
const ERROR_OCCURRED = createAITracker((properties) => ({
|
|
2342
|
+
name: AI_EVENTS.ERROR_OCCURRED,
|
|
2343
|
+
category: "system",
|
|
2344
|
+
properties,
|
|
2345
|
+
requiredProperties: []
|
|
2346
|
+
}));
|
|
2347
|
+
/**
|
|
2348
|
+
* Track rate limit hit
|
|
2349
|
+
*
|
|
2350
|
+
* @example
|
|
2351
|
+
* ```typescript
|
|
2352
|
+
* ai.RATE_LIMIT_HIT({
|
|
2353
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2354
|
+
* user_id: 'user_123',
|
|
2355
|
+
* limit_type: 'requests-per-minute',
|
|
2356
|
+
* retry_after_seconds: 60,
|
|
2357
|
+
* });
|
|
2358
|
+
* ```
|
|
2359
|
+
*/
|
|
2360
|
+
const RATE_LIMIT_HIT = createAITracker((properties) => ({
|
|
2361
|
+
name: AI_EVENTS.RATE_LIMIT_HIT,
|
|
2362
|
+
category: "system",
|
|
2363
|
+
properties,
|
|
2364
|
+
requiredProperties: []
|
|
2365
|
+
}));
|
|
2366
|
+
/**
|
|
2367
|
+
* Track token usage
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* ```typescript
|
|
2371
|
+
* ai.TOKEN_USAGE_TRACKED({
|
|
2372
|
+
* conversation_id: 'conv_123',
|
|
2373
|
+
* model_id: 'gpt-4',
|
|
2374
|
+
* input_tokens: 1500,
|
|
2375
|
+
* output_tokens: 800,
|
|
2376
|
+
* total_tokens: 2300,
|
|
2377
|
+
* cost: 0.0345,
|
|
2378
|
+
* cost_currency: 'USD',
|
|
2379
|
+
* });
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
const TOKEN_USAGE_TRACKED = createAITracker((properties) => ({
|
|
2383
|
+
name: AI_EVENTS.TOKEN_USAGE_TRACKED,
|
|
2384
|
+
category: "system",
|
|
2385
|
+
properties,
|
|
2386
|
+
requiredProperties: []
|
|
2387
|
+
}));
|
|
2388
|
+
/**
|
|
2389
|
+
* Track performance measurement
|
|
2390
|
+
*
|
|
2391
|
+
* @example
|
|
2392
|
+
* ```typescript
|
|
2393
|
+
* ai.PERFORMANCE_MEASURED({
|
|
2394
|
+
* conversation_id: 'conv_123',
|
|
2395
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2396
|
+
* operation_type: 'message-generation',
|
|
2397
|
+
* duration_ms: 850,
|
|
2398
|
+
* performance_tier: 'normal',
|
|
2399
|
+
* });
|
|
2400
|
+
* ```
|
|
2401
|
+
*/
|
|
2402
|
+
const PERFORMANCE_MEASURED = createAITracker((properties) => ({
|
|
2403
|
+
name: AI_EVENTS.PERFORMANCE_MEASURED,
|
|
2404
|
+
category: "system",
|
|
2405
|
+
properties,
|
|
2406
|
+
requiredProperties: []
|
|
2407
|
+
}));
|
|
2408
|
+
/**
|
|
2409
|
+
* Track tool call start
|
|
2410
|
+
*
|
|
2411
|
+
* @example
|
|
2412
|
+
* ```typescript
|
|
2413
|
+
* ai.TOOL_CALL_STARTED({
|
|
2414
|
+
* conversation_id: 'conv_123',
|
|
2415
|
+
* model_id: 'gpt-4',
|
|
2416
|
+
* tool_name: 'web_search',
|
|
2417
|
+
* tool_type: 'built-in',
|
|
2418
|
+
* });
|
|
2419
|
+
* ```
|
|
2420
|
+
*/
|
|
2421
|
+
const TOOL_CALL_STARTED = createAITracker((properties) => ({
|
|
2422
|
+
name: AI_EVENTS.TOOL_CALL_STARTED,
|
|
2423
|
+
category: "tool",
|
|
2424
|
+
properties,
|
|
2425
|
+
requiredProperties: []
|
|
2426
|
+
}));
|
|
2427
|
+
/**
|
|
2428
|
+
* Track tool call completion
|
|
2429
|
+
*
|
|
2430
|
+
* @example
|
|
2431
|
+
* ```typescript
|
|
2432
|
+
* ai.TOOL_CALL_COMPLETED({
|
|
2433
|
+
* conversation_id: 'conv_123',
|
|
2434
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2435
|
+
* tool_name: 'calculator',
|
|
2436
|
+
* tool_type: 'custom',
|
|
2437
|
+
* result_status: 'success',
|
|
2438
|
+
* execution_time_ms: 50,
|
|
2439
|
+
* });
|
|
2440
|
+
* ```
|
|
2441
|
+
*/
|
|
2442
|
+
const TOOL_CALL_COMPLETED = createAITracker((properties) => ({
|
|
2443
|
+
name: AI_EVENTS.TOOL_CALL_COMPLETED,
|
|
2444
|
+
category: "tool",
|
|
2445
|
+
properties,
|
|
2446
|
+
requiredProperties: []
|
|
2447
|
+
}));
|
|
2448
|
+
/**
|
|
2449
|
+
* Track tool call failure
|
|
2450
|
+
*
|
|
2451
|
+
* @example
|
|
2452
|
+
* ```typescript
|
|
2453
|
+
* ai.TOOL_CALL_FAILED({
|
|
2454
|
+
* conversation_id: 'conv_123',
|
|
2455
|
+
* model_id: 'gpt-4',
|
|
2456
|
+
* tool_name: 'api_caller',
|
|
2457
|
+
* tool_type: 'custom',
|
|
2458
|
+
* error_message: 'Connection timeout',
|
|
2459
|
+
* execution_time_ms: 5000,
|
|
2460
|
+
* });
|
|
2461
|
+
* ```
|
|
2462
|
+
*/
|
|
2463
|
+
const TOOL_CALL_FAILED = createAITracker((properties) => ({
|
|
2464
|
+
name: AI_EVENTS.TOOL_CALL_FAILED,
|
|
2465
|
+
category: "tool",
|
|
2466
|
+
properties,
|
|
2467
|
+
requiredProperties: []
|
|
2468
|
+
}));
|
|
2469
|
+
/**
|
|
2470
|
+
* Track function execution
|
|
2471
|
+
*
|
|
2472
|
+
* @example
|
|
2473
|
+
* ```typescript
|
|
2474
|
+
* ai.FUNCTION_EXECUTED({
|
|
2475
|
+
* conversation_id: 'conv_123',
|
|
2476
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2477
|
+
* function_name: 'getData',
|
|
2478
|
+
* execution_status: 'success',
|
|
2479
|
+
* execution_time_ms: 120,
|
|
2480
|
+
* });
|
|
2481
|
+
* ```
|
|
2482
|
+
*/
|
|
2483
|
+
const FUNCTION_EXECUTED = createAITracker((properties) => ({
|
|
2484
|
+
name: AI_EVENTS.FUNCTION_EXECUTED,
|
|
2485
|
+
category: "tool",
|
|
2486
|
+
properties,
|
|
2487
|
+
requiredProperties: []
|
|
2488
|
+
}));
|
|
2489
|
+
/**
|
|
2490
|
+
* Track API request
|
|
2491
|
+
*
|
|
2492
|
+
* @example
|
|
2493
|
+
* ```typescript
|
|
2494
|
+
* ai.API_REQUEST_MADE({
|
|
2495
|
+
* conversation_id: 'conv_123',
|
|
2496
|
+
* model_id: 'gpt-4',
|
|
2497
|
+
* api_endpoint: '/v1/data',
|
|
2498
|
+
* api_method: 'GET',
|
|
2499
|
+
* response_status: 200,
|
|
2500
|
+
* response_time_ms: 250,
|
|
2501
|
+
* });
|
|
2502
|
+
* ```
|
|
2503
|
+
*/
|
|
2504
|
+
const API_REQUEST_MADE = createAITracker((properties) => ({
|
|
2505
|
+
name: AI_EVENTS.API_REQUEST_MADE,
|
|
2506
|
+
category: "tool",
|
|
2507
|
+
properties,
|
|
2508
|
+
requiredProperties: []
|
|
2509
|
+
}));
|
|
2510
|
+
/**
|
|
2511
|
+
* Track plugin activation
|
|
2512
|
+
*
|
|
2513
|
+
* @example
|
|
2514
|
+
* ```typescript
|
|
2515
|
+
* ai.PLUGIN_ACTIVATED({
|
|
2516
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2517
|
+
* plugin_name: 'web-browser',
|
|
2518
|
+
* plugin_version: '1.2.0',
|
|
2519
|
+
* });
|
|
2520
|
+
* ```
|
|
2521
|
+
*/
|
|
2522
|
+
const PLUGIN_ACTIVATED = createAITracker((properties) => ({
|
|
2523
|
+
name: AI_EVENTS.PLUGIN_ACTIVATED,
|
|
2524
|
+
category: "tool",
|
|
2525
|
+
properties,
|
|
2526
|
+
requiredProperties: []
|
|
2527
|
+
}));
|
|
2528
|
+
/**
|
|
2529
|
+
* Track extension usage
|
|
2530
|
+
*
|
|
2531
|
+
* @example
|
|
2532
|
+
* ```typescript
|
|
2533
|
+
* ai.EXTENSION_USED({
|
|
2534
|
+
* conversation_id: 'conv_123',
|
|
2535
|
+
* model_id: 'gpt-4',
|
|
2536
|
+
* extension_name: 'code-runner',
|
|
2537
|
+
* extension_action: 'execute',
|
|
2538
|
+
* });
|
|
2539
|
+
* ```
|
|
2540
|
+
*/
|
|
2541
|
+
const EXTENSION_USED = createAITracker((properties) => ({
|
|
2542
|
+
name: AI_EVENTS.EXTENSION_USED,
|
|
2543
|
+
category: "tool",
|
|
2544
|
+
properties,
|
|
2545
|
+
requiredProperties: []
|
|
2546
|
+
}));
|
|
2547
|
+
/**
|
|
2548
|
+
* Track web search
|
|
2549
|
+
*
|
|
2550
|
+
* @example
|
|
2551
|
+
* ```typescript
|
|
2552
|
+
* ai.WEB_SEARCH_PERFORMED({
|
|
2553
|
+
* conversation_id: 'conv_123',
|
|
2554
|
+
* model_id: 'gpt-4',
|
|
2555
|
+
* search_query: 'latest React 19 features',
|
|
2556
|
+
* search_engine: 'google',
|
|
2557
|
+
* results_count: 10,
|
|
2558
|
+
* search_time_ms: 450,
|
|
2559
|
+
* });
|
|
2560
|
+
* ```
|
|
2561
|
+
*/
|
|
2562
|
+
const WEB_SEARCH_PERFORMED = createAITracker((properties) => ({
|
|
2563
|
+
name: AI_EVENTS.WEB_SEARCH_PERFORMED,
|
|
2564
|
+
category: "context",
|
|
2565
|
+
properties,
|
|
2566
|
+
requiredProperties: ["query", "search_scope"]
|
|
2567
|
+
}));
|
|
2568
|
+
/**
|
|
2569
|
+
* Track citation addition
|
|
2570
|
+
*
|
|
2571
|
+
* @example
|
|
2572
|
+
* ```typescript
|
|
2573
|
+
* ai.CITATION_ADDED({
|
|
2574
|
+
* conversation_id: 'conv_123',
|
|
2575
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2576
|
+
* message_id: 'msg_461',
|
|
2577
|
+
* citation_source: 'https://react.dev',
|
|
2578
|
+
* citation_type: 'web',
|
|
2579
|
+
* });
|
|
2580
|
+
* ```
|
|
2581
|
+
*/
|
|
2582
|
+
const CITATION_ADDED = createAITracker((properties) => ({
|
|
2583
|
+
name: AI_EVENTS.CITATION_ADDED,
|
|
2584
|
+
category: "context",
|
|
2585
|
+
properties,
|
|
2586
|
+
requiredProperties: ["query", "search_scope"]
|
|
2587
|
+
}));
|
|
2588
|
+
/**
|
|
2589
|
+
* Track browse session start
|
|
2590
|
+
*
|
|
2591
|
+
* @example
|
|
2592
|
+
* ```typescript
|
|
2593
|
+
* ai.BROWSE_SESSION_STARTED({
|
|
2594
|
+
* conversation_id: 'conv_123',
|
|
2595
|
+
* model_id: 'gpt-4',
|
|
2596
|
+
* browse_target_url: 'https://example.com',
|
|
2597
|
+
* });
|
|
2598
|
+
* ```
|
|
2599
|
+
*/
|
|
2600
|
+
const BROWSE_SESSION_STARTED = createAITracker((properties) => ({
|
|
2601
|
+
name: AI_EVENTS.BROWSE_SESSION_STARTED,
|
|
2602
|
+
category: "context",
|
|
2603
|
+
properties,
|
|
2604
|
+
requiredProperties: ["query", "search_scope"]
|
|
2605
|
+
}));
|
|
2606
|
+
/**
|
|
2607
|
+
* Track page content fetch
|
|
2608
|
+
*
|
|
2609
|
+
* @example
|
|
2610
|
+
* ```typescript
|
|
2611
|
+
* ai.PAGE_CONTENT_FETCHED({
|
|
2612
|
+
* conversation_id: 'conv_123',
|
|
2613
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2614
|
+
* page_url: 'https://example.com/article',
|
|
2615
|
+
* content_length: 5000,
|
|
2616
|
+
* fetch_time_ms: 800,
|
|
2617
|
+
* });
|
|
2618
|
+
* ```
|
|
2619
|
+
*/
|
|
2620
|
+
const PAGE_CONTENT_FETCHED = createAITracker((properties) => ({
|
|
2621
|
+
name: AI_EVENTS.PAGE_CONTENT_FETCHED,
|
|
2622
|
+
category: "context",
|
|
2623
|
+
properties,
|
|
2624
|
+
requiredProperties: ["query", "search_scope"]
|
|
2625
|
+
}));
|
|
2626
|
+
/**
|
|
2627
|
+
* Track search results ranking
|
|
2628
|
+
*
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```typescript
|
|
2631
|
+
* ai.SEARCH_RESULTS_RANKED({
|
|
2632
|
+
* conversation_id: 'conv_123',
|
|
2633
|
+
* model_id: 'gpt-4',
|
|
2634
|
+
* results_count: 20,
|
|
2635
|
+
* ranking_algorithm: 'relevance',
|
|
2636
|
+
* });
|
|
2637
|
+
* ```
|
|
2638
|
+
*/
|
|
2639
|
+
const SEARCH_RESULTS_RANKED = createAITracker((properties) => ({
|
|
2640
|
+
name: AI_EVENTS.SEARCH_RESULTS_RANKED,
|
|
2641
|
+
category: "context",
|
|
2642
|
+
properties,
|
|
2643
|
+
requiredProperties: ["query", "search_scope"]
|
|
2644
|
+
}));
|
|
2645
|
+
/**
|
|
2646
|
+
* Track external source access
|
|
2647
|
+
*
|
|
2648
|
+
* @example
|
|
2649
|
+
* ```typescript
|
|
2650
|
+
* ai.EXTERNAL_SOURCE_ACCESSED({
|
|
2651
|
+
* conversation_id: 'conv_123',
|
|
2652
|
+
* model_id: 'claude-3-5-sonnet',
|
|
2653
|
+
* source_type: 'api',
|
|
2654
|
+
* source_url: 'https://api.example.com/data',
|
|
2655
|
+
* access_time_ms: 350,
|
|
2656
|
+
* });
|
|
2657
|
+
* ```
|
|
2658
|
+
*/
|
|
2659
|
+
const EXTERNAL_SOURCE_ACCESSED = createAITracker((properties) => ({
|
|
2660
|
+
name: AI_EVENTS.EXTERNAL_SOURCE_ACCESSED,
|
|
2661
|
+
category: "context",
|
|
2662
|
+
properties,
|
|
2663
|
+
requiredProperties: ["query", "search_scope"]
|
|
2664
|
+
}));
|
|
2665
|
+
|
|
2666
|
+
//#endregion
|
|
2667
|
+
//#region src/shared/emitters/ai/events/agent.ts
|
|
2668
|
+
/**
|
|
2669
|
+
* @fileoverview Agent-related AI SDK v6 events
|
|
2670
|
+
* Agent-related AI SDK v6 events
|
|
2671
|
+
*/
|
|
2672
|
+
/**
|
|
2673
|
+
* Track when an AI agent is created
|
|
2674
|
+
*/
|
|
2675
|
+
function agentCreated(properties, options) {
|
|
2676
|
+
validateRequiredProperties(properties, ["model_id"]);
|
|
2677
|
+
const normalizedProps = {
|
|
2678
|
+
...normalizeBaseProperties(properties),
|
|
2679
|
+
agent_type: properties.agent_type,
|
|
2680
|
+
system_prompt_length: properties.system_prompt_length,
|
|
2681
|
+
tools_available: properties.tools_available,
|
|
2682
|
+
tools_count: properties.tools_count
|
|
2683
|
+
};
|
|
2684
|
+
return trackAISDK({
|
|
2685
|
+
name: AI_SDK_EVENTS.AGENT_CREATED,
|
|
2686
|
+
category: "ai-sdk",
|
|
2687
|
+
properties: cleanProperties(normalizedProps),
|
|
2688
|
+
requiredProperties: ["model_id"]
|
|
2689
|
+
}, options);
|
|
2690
|
+
}
|
|
2691
|
+
/**
|
|
2692
|
+
* Track when an AI agent execution starts
|
|
2693
|
+
*/
|
|
2694
|
+
function agentExecutionStarted(properties, options) {
|
|
2695
|
+
validateRequiredProperties(properties, ["model_id", "agent_id"]);
|
|
2696
|
+
const normalizedProps = {
|
|
2697
|
+
...normalizeBaseProperties(properties),
|
|
2698
|
+
agent_type: properties.agent_type
|
|
2699
|
+
};
|
|
2700
|
+
return trackAISDK({
|
|
2701
|
+
name: AI_SDK_EVENTS.AGENT_EXECUTION_STARTED,
|
|
2702
|
+
category: "ai-sdk",
|
|
2703
|
+
properties: cleanProperties(normalizedProps),
|
|
2704
|
+
requiredProperties: ["model_id", "agent_id"]
|
|
2705
|
+
}, options);
|
|
2706
|
+
}
|
|
2707
|
+
/**
|
|
2708
|
+
* Track when an AI agent execution completes successfully
|
|
2709
|
+
*/
|
|
2710
|
+
function agentExecutionCompleted(properties, options) {
|
|
2711
|
+
validateRequiredProperties(properties, [
|
|
2712
|
+
"model_id",
|
|
2713
|
+
"agent_id",
|
|
2714
|
+
"status"
|
|
2715
|
+
]);
|
|
2716
|
+
const normalizedProps = {
|
|
2717
|
+
...normalizeBaseProperties(properties),
|
|
2718
|
+
...normalizeTokenUsage(properties),
|
|
2719
|
+
completion_type: properties.completion_type,
|
|
2720
|
+
status: properties.status,
|
|
2721
|
+
total_duration_ms: properties.total_duration_ms,
|
|
2722
|
+
step_count: properties.step_count,
|
|
2723
|
+
finish_reason: properties.finish_reason,
|
|
2724
|
+
has_tools: properties.has_tools
|
|
2725
|
+
};
|
|
2726
|
+
return trackAISDK({
|
|
2727
|
+
name: AI_SDK_EVENTS.AGENT_EXECUTION_COMPLETED,
|
|
2728
|
+
category: "ai-sdk",
|
|
2729
|
+
properties: cleanProperties(normalizedProps),
|
|
2730
|
+
requiredProperties: [
|
|
2731
|
+
"model_id",
|
|
2732
|
+
"agent_id",
|
|
2733
|
+
"status"
|
|
2734
|
+
]
|
|
2735
|
+
}, options);
|
|
2736
|
+
}
|
|
2737
|
+
/**
|
|
2738
|
+
* Track when an AI agent execution fails
|
|
2739
|
+
*/
|
|
2740
|
+
function agentExecutionFailed(properties, options) {
|
|
2741
|
+
validateRequiredProperties(properties, [
|
|
2742
|
+
"model_id",
|
|
2743
|
+
"agent_id",
|
|
2744
|
+
"error_message"
|
|
2745
|
+
]);
|
|
2746
|
+
const normalizedProps = {
|
|
2747
|
+
...normalizeBaseProperties(properties),
|
|
2748
|
+
...normalizeTokenUsage(properties),
|
|
2749
|
+
completion_type: properties.completion_type,
|
|
2750
|
+
status: "failed",
|
|
2751
|
+
error_message: properties.error_message,
|
|
2752
|
+
retry_count: properties.retry_count,
|
|
2753
|
+
total_duration_ms: properties.total_duration_ms
|
|
2754
|
+
};
|
|
2755
|
+
return trackAISDK({
|
|
2756
|
+
name: AI_SDK_EVENTS.AGENT_EXECUTION_FAILED,
|
|
2757
|
+
category: "ai-sdk",
|
|
2758
|
+
properties: cleanProperties(normalizedProps),
|
|
2759
|
+
requiredProperties: [
|
|
2760
|
+
"model_id",
|
|
2761
|
+
"agent_id",
|
|
2762
|
+
"error_message"
|
|
2763
|
+
]
|
|
2764
|
+
}, options);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
//#endregion
|
|
2768
|
+
//#region src/shared/emitters/ai/events/chat.ts
|
|
2769
|
+
/**
|
|
2770
|
+
* @fileoverview Chat-related AI SDK v6 events
|
|
2771
|
+
* Chat-related AI SDK v6 events
|
|
2772
|
+
*/
|
|
2773
|
+
/**
|
|
2774
|
+
* Track when a chat session starts
|
|
2775
|
+
*/
|
|
2776
|
+
function chatSessionStarted(properties, options) {
|
|
2777
|
+
validateRequiredProperties(properties, ["model_id", "session_id"]);
|
|
2778
|
+
const normalizedProps = {
|
|
2779
|
+
...normalizeBaseProperties(properties),
|
|
2780
|
+
session_type: properties.session_type
|
|
2781
|
+
};
|
|
2782
|
+
return trackAISDK({
|
|
2783
|
+
name: AI_SDK_EVENTS.CHAT_SESSION_STARTED,
|
|
2784
|
+
category: "ai-sdk",
|
|
2785
|
+
properties: cleanProperties(normalizedProps),
|
|
2786
|
+
requiredProperties: ["model_id", "session_id"]
|
|
2787
|
+
}, options);
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Track when a chat session ends
|
|
2791
|
+
*/
|
|
2792
|
+
function chatSessionEnded(properties, options) {
|
|
2793
|
+
validateRequiredProperties(properties, ["model_id", "session_id"]);
|
|
2794
|
+
const normalizedProps = {
|
|
2795
|
+
...normalizeBaseProperties(properties),
|
|
2796
|
+
duration_ms: properties.duration_ms,
|
|
2797
|
+
message_count: properties.message_count,
|
|
2798
|
+
tool_calls_count: properties.tool_calls_count,
|
|
2799
|
+
total_tokens: properties.total_tokens,
|
|
2800
|
+
session_end_reason: properties.session_end_reason
|
|
2801
|
+
};
|
|
2802
|
+
return trackAISDK({
|
|
2803
|
+
name: AI_SDK_EVENTS.CHAT_SESSION_ENDED,
|
|
2804
|
+
category: "ai-sdk",
|
|
2805
|
+
properties: cleanProperties(normalizedProps),
|
|
2806
|
+
requiredProperties: ["model_id", "session_id"]
|
|
2807
|
+
}, options);
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* Track when a user sends a chat message
|
|
2811
|
+
*/
|
|
2812
|
+
function chatMessageSent(properties, options) {
|
|
2813
|
+
validateRequiredProperties(properties, ["model_id", "message_role"]);
|
|
2814
|
+
const normalizedProps = {
|
|
2815
|
+
...normalizeBaseProperties(properties),
|
|
2816
|
+
message_id: properties.message_id,
|
|
2817
|
+
message_role: properties.message_role,
|
|
2818
|
+
message_length: properties.message_length,
|
|
2819
|
+
message_index: properties.message_index,
|
|
2820
|
+
has_images: properties.has_images,
|
|
2821
|
+
parent_message_id: properties.parent_message_id
|
|
2822
|
+
};
|
|
2823
|
+
return trackAISDK({
|
|
2824
|
+
name: AI_SDK_EVENTS.CHAT_MESSAGE_SENT,
|
|
2825
|
+
category: "ai-sdk",
|
|
2826
|
+
properties: cleanProperties(normalizedProps),
|
|
2827
|
+
requiredProperties: ["model_id", "message_role"]
|
|
2828
|
+
}, options);
|
|
2829
|
+
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Track when the assistant's chat message is received
|
|
2832
|
+
*/
|
|
2833
|
+
function chatMessageReceived(properties, options) {
|
|
2834
|
+
validateRequiredProperties(properties, ["model_id", "message_role"]);
|
|
2835
|
+
const normalizedProps = {
|
|
2836
|
+
...normalizeBaseProperties(properties),
|
|
2837
|
+
message_id: properties.message_id,
|
|
2838
|
+
message_role: properties.message_role,
|
|
2839
|
+
message_length: properties.message_length,
|
|
2840
|
+
message_index: properties.message_index,
|
|
2841
|
+
finish_reason: properties.finish_reason,
|
|
2842
|
+
response_time_ms: properties.response_time_ms,
|
|
2843
|
+
is_streaming: properties.is_streaming
|
|
2844
|
+
};
|
|
2845
|
+
return trackAISDK({
|
|
2846
|
+
name: AI_SDK_EVENTS.CHAT_MESSAGE_RECEIVED,
|
|
2847
|
+
category: "ai-sdk",
|
|
2848
|
+
properties: cleanProperties(normalizedProps),
|
|
2849
|
+
requiredProperties: ["model_id", "message_role"]
|
|
2850
|
+
}, options);
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
//#endregion
|
|
2854
|
+
//#region src/shared/emitters/ai/events/chatbot-ecommerce.ts
|
|
2855
|
+
/**
|
|
2856
|
+
* @fileoverview E-commerce chatbot-specific AI SDK v6 events
|
|
2857
|
+
* E-commerce chatbot-specific AI SDK v6 events
|
|
2858
|
+
*/
|
|
2859
|
+
/**
|
|
2860
|
+
* Maximum number of product IDs to include in chatbot ecommerce events.
|
|
2861
|
+
* Limits payload size and prevents excessive data in analytics.
|
|
2862
|
+
*/
|
|
2863
|
+
const MAX_PRODUCT_IDS = 20;
|
|
2864
|
+
/**
|
|
2865
|
+
* Track when chatbot detects user intent
|
|
2866
|
+
*/
|
|
2867
|
+
function chatbotIntentDetected(properties, options) {
|
|
2868
|
+
validateRequiredProperties(properties, ["model_id", "message"]);
|
|
2869
|
+
const intent = properties.intent_detected ?? detectChatbotIntent(properties.message);
|
|
2870
|
+
const normalizedProps = {
|
|
2871
|
+
...normalizeBaseProperties(properties),
|
|
2872
|
+
intent_detected: intent
|
|
2873
|
+
};
|
|
2874
|
+
return trackAISDK({
|
|
2875
|
+
name: AI_SDK_EVENTS.CHATBOT_INTENT_DETECTED,
|
|
2876
|
+
category: "ai-sdk",
|
|
2877
|
+
properties: cleanProperties(normalizedProps),
|
|
2878
|
+
requiredProperties: ["model_id"]
|
|
2879
|
+
}, options);
|
|
2880
|
+
}
|
|
2881
|
+
/**
|
|
2882
|
+
* Track when chatbot assists with cart operations
|
|
2883
|
+
*/
|
|
2884
|
+
function chatbotCartAssisted(properties, options) {
|
|
2885
|
+
validateRequiredProperties(properties, ["model_id", "cart_id"]);
|
|
2886
|
+
const normalizedProps = {
|
|
2887
|
+
...normalizeBaseProperties(properties),
|
|
2888
|
+
cart_id: properties.cart_id,
|
|
2889
|
+
cart_value: properties.cart_value,
|
|
2890
|
+
product_count: properties.product_count,
|
|
2891
|
+
product_ids: properties.product_ids ? truncateArray(properties.product_ids, MAX_PRODUCT_IDS) : void 0,
|
|
2892
|
+
intent_detected: properties.intent_detected
|
|
2893
|
+
};
|
|
2894
|
+
return trackAISDK({
|
|
2895
|
+
name: AI_SDK_EVENTS.CHATBOT_CART_ASSISTED,
|
|
2896
|
+
category: "ai-sdk",
|
|
2897
|
+
properties: cleanProperties(normalizedProps),
|
|
2898
|
+
requiredProperties: ["model_id", "cart_id"]
|
|
2899
|
+
}, options);
|
|
2900
|
+
}
|
|
2901
|
+
/**
|
|
2902
|
+
* Track when chatbot assists with order-related queries
|
|
2903
|
+
*/
|
|
2904
|
+
function chatbotOrderAssisted(properties, options) {
|
|
2905
|
+
validateRequiredProperties(properties, ["model_id", "order_id"]);
|
|
2906
|
+
const normalizedProps = {
|
|
2907
|
+
...normalizeBaseProperties(properties),
|
|
2908
|
+
order_id: properties.order_id,
|
|
2909
|
+
intent_detected: properties.intent_detected
|
|
2910
|
+
};
|
|
2911
|
+
return trackAISDK({
|
|
2912
|
+
name: AI_SDK_EVENTS.CHATBOT_ORDER_ASSISTED,
|
|
2913
|
+
category: "ai-sdk",
|
|
2914
|
+
properties: cleanProperties(normalizedProps),
|
|
2915
|
+
requiredProperties: ["model_id", "order_id"]
|
|
2916
|
+
}, options);
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Track when chatbot shows product recommendations
|
|
2920
|
+
*/
|
|
2921
|
+
function chatbotProductRecommended(properties, options) {
|
|
2922
|
+
validateRequiredProperties(properties, ["model_id", "product_ids"]);
|
|
2923
|
+
const normalizedProps = {
|
|
2924
|
+
...normalizeBaseProperties(properties),
|
|
2925
|
+
product_count: properties.product_count ?? properties.product_ids?.length,
|
|
2926
|
+
product_ids: properties.product_ids ? truncateArray(properties.product_ids, MAX_PRODUCT_IDS) : void 0,
|
|
2927
|
+
recommendation_shown: true,
|
|
2928
|
+
intent_detected: properties.intent_detected
|
|
2929
|
+
};
|
|
2930
|
+
return trackAISDK({
|
|
2931
|
+
name: AI_SDK_EVENTS.CHATBOT_PRODUCT_RECOMMENDED,
|
|
2932
|
+
category: "ai-sdk",
|
|
2933
|
+
properties: cleanProperties(normalizedProps),
|
|
2934
|
+
requiredProperties: ["model_id", "product_ids"]
|
|
2935
|
+
}, options);
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
//#endregion
|
|
2939
|
+
//#region src/shared/emitters/ai/events/completion.ts
|
|
2940
|
+
/**
|
|
2941
|
+
* @fileoverview Completion-related AI SDK v6 events
|
|
2942
|
+
* Completion-related AI SDK v6 events
|
|
2943
|
+
*/
|
|
2944
|
+
/**
|
|
2945
|
+
* Track when a completion is requested
|
|
2946
|
+
*/
|
|
2947
|
+
function completionRequested(properties, options) {
|
|
2948
|
+
validateRequiredProperties(properties, ["model_id", "completion_type"]);
|
|
2949
|
+
const normalizedProps = {
|
|
2950
|
+
...normalizeBaseProperties(properties),
|
|
2951
|
+
...normalizeModelConfig(properties),
|
|
2952
|
+
completion_type: properties.completion_type,
|
|
2953
|
+
prompt_length: properties.prompt_length,
|
|
2954
|
+
has_tools: properties.has_tools
|
|
2955
|
+
};
|
|
2956
|
+
return trackAISDK({
|
|
2957
|
+
name: AI_SDK_EVENTS.COMPLETION_REQUESTED,
|
|
2958
|
+
category: "ai-sdk",
|
|
2959
|
+
properties: cleanProperties(normalizedProps),
|
|
2960
|
+
requiredProperties: ["model_id", "completion_type"]
|
|
2961
|
+
}, options);
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Track when a completion is successfully generated
|
|
2965
|
+
*/
|
|
2966
|
+
function completionGenerated(properties, options) {
|
|
2967
|
+
validateRequiredProperties(properties, [
|
|
2968
|
+
"model_id",
|
|
2969
|
+
"completion_type",
|
|
2970
|
+
"status"
|
|
2971
|
+
]);
|
|
2972
|
+
const normalizedProps = {
|
|
2973
|
+
...normalizeBaseProperties(properties),
|
|
2974
|
+
...normalizeTokenUsage(properties),
|
|
2975
|
+
...normalizeModelConfig(properties),
|
|
2976
|
+
completion_type: properties.completion_type,
|
|
2977
|
+
status: properties.status,
|
|
2978
|
+
finish_reason: properties.finish_reason,
|
|
2979
|
+
total_duration_ms: properties.total_duration_ms,
|
|
2980
|
+
step_count: properties.step_count,
|
|
2981
|
+
retry_count: properties.retry_count
|
|
2982
|
+
};
|
|
2983
|
+
return trackAISDK({
|
|
2984
|
+
name: AI_SDK_EVENTS.COMPLETION_GENERATED,
|
|
2985
|
+
category: "ai-sdk",
|
|
2986
|
+
properties: cleanProperties(normalizedProps),
|
|
2987
|
+
requiredProperties: [
|
|
2988
|
+
"model_id",
|
|
2989
|
+
"completion_type",
|
|
2990
|
+
"status"
|
|
2991
|
+
]
|
|
2992
|
+
}, options);
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Track when a completion fails
|
|
2996
|
+
*/
|
|
2997
|
+
function completionFailed(properties, options) {
|
|
2998
|
+
validateRequiredProperties(properties, [
|
|
2999
|
+
"model_id",
|
|
3000
|
+
"completion_type",
|
|
3001
|
+
"error_message"
|
|
3002
|
+
]);
|
|
3003
|
+
const normalizedProps = {
|
|
3004
|
+
...normalizeBaseProperties(properties),
|
|
3005
|
+
...normalizeTokenUsage(properties),
|
|
3006
|
+
completion_type: properties.completion_type,
|
|
3007
|
+
status: "failed",
|
|
3008
|
+
error_message: properties.error_message,
|
|
3009
|
+
retry_count: properties.retry_count,
|
|
3010
|
+
total_duration_ms: properties.total_duration_ms
|
|
3011
|
+
};
|
|
3012
|
+
return trackAISDK({
|
|
3013
|
+
name: AI_SDK_EVENTS.COMPLETION_FAILED,
|
|
3014
|
+
category: "ai-sdk",
|
|
3015
|
+
properties: cleanProperties(normalizedProps),
|
|
3016
|
+
requiredProperties: [
|
|
3017
|
+
"model_id",
|
|
3018
|
+
"completion_type",
|
|
3019
|
+
"error_message"
|
|
3020
|
+
]
|
|
3021
|
+
}, options);
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
//#endregion
|
|
3025
|
+
//#region src/shared/emitters/ai/events/streaming.ts
|
|
3026
|
+
/**
|
|
3027
|
+
* @fileoverview Streaming-related AI SDK v6 events
|
|
3028
|
+
* Streaming-related AI SDK v6 events
|
|
3029
|
+
*/
|
|
3030
|
+
/**
|
|
3031
|
+
* Track when streaming starts
|
|
3032
|
+
*/
|
|
3033
|
+
function streamStarted(properties, options) {
|
|
3034
|
+
validateRequiredProperties(properties, ["model_id", "stream_type"]);
|
|
3035
|
+
const normalizedProps = {
|
|
3036
|
+
...normalizeBaseProperties(properties),
|
|
3037
|
+
stream_type: properties.stream_type
|
|
3038
|
+
};
|
|
3039
|
+
return trackAISDK({
|
|
3040
|
+
name: AI_SDK_EVENTS.STREAM_STARTED,
|
|
3041
|
+
category: "ai-sdk",
|
|
3042
|
+
properties: cleanProperties(normalizedProps),
|
|
3043
|
+
requiredProperties: ["model_id", "stream_type"]
|
|
3044
|
+
}, options);
|
|
3045
|
+
}
|
|
3046
|
+
/**
|
|
3047
|
+
* Track when a stream chunk is received
|
|
3048
|
+
*/
|
|
3049
|
+
function streamChunkReceived(properties, options) {
|
|
3050
|
+
validateRequiredProperties(properties, ["model_id", "stream_type"]);
|
|
3051
|
+
const normalizedProps = {
|
|
3052
|
+
...normalizeBaseProperties(properties),
|
|
3053
|
+
stream_type: properties.stream_type,
|
|
3054
|
+
chunk_index: properties.chunk_index
|
|
3055
|
+
};
|
|
3056
|
+
return trackAISDK({
|
|
3057
|
+
name: AI_SDK_EVENTS.STREAM_CHUNK_RECEIVED,
|
|
3058
|
+
category: "ai-sdk",
|
|
3059
|
+
properties: cleanProperties(normalizedProps),
|
|
3060
|
+
requiredProperties: ["model_id", "stream_type"]
|
|
3061
|
+
}, options);
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* Track when streaming completes
|
|
3065
|
+
*/
|
|
3066
|
+
function streamCompleted(properties, options) {
|
|
3067
|
+
validateRequiredProperties(properties, ["model_id", "stream_type"]);
|
|
3068
|
+
const normalizedProps = {
|
|
3069
|
+
...normalizeBaseProperties(properties),
|
|
3070
|
+
stream_type: properties.stream_type,
|
|
3071
|
+
chunk_count: properties.chunk_count,
|
|
3072
|
+
stream_duration_ms: properties.stream_duration_ms,
|
|
3073
|
+
time_to_first_chunk_ms: properties.time_to_first_chunk_ms,
|
|
3074
|
+
chunks_per_second: properties.chunks_per_second
|
|
3075
|
+
};
|
|
3076
|
+
return trackAISDK({
|
|
3077
|
+
name: AI_SDK_EVENTS.STREAM_COMPLETED,
|
|
3078
|
+
category: "ai-sdk",
|
|
3079
|
+
properties: cleanProperties(normalizedProps),
|
|
3080
|
+
requiredProperties: ["model_id", "stream_type"]
|
|
3081
|
+
}, options);
|
|
3082
|
+
}
|
|
3083
|
+
/**
|
|
3084
|
+
* Track when streaming fails
|
|
3085
|
+
*/
|
|
3086
|
+
function streamFailed(properties, options) {
|
|
3087
|
+
validateRequiredProperties(properties, [
|
|
3088
|
+
"model_id",
|
|
3089
|
+
"stream_type",
|
|
3090
|
+
"error_message"
|
|
3091
|
+
]);
|
|
3092
|
+
const normalizedProps = {
|
|
3093
|
+
...normalizeBaseProperties(properties),
|
|
3094
|
+
stream_type: properties.stream_type,
|
|
3095
|
+
error_message: properties.error_message,
|
|
3096
|
+
chunk_count: properties.chunk_count,
|
|
3097
|
+
stream_duration_ms: properties.stream_duration_ms
|
|
3098
|
+
};
|
|
3099
|
+
return trackAISDK({
|
|
3100
|
+
name: AI_SDK_EVENTS.STREAM_FAILED,
|
|
3101
|
+
category: "ai-sdk",
|
|
3102
|
+
properties: cleanProperties(normalizedProps),
|
|
3103
|
+
requiredProperties: [
|
|
3104
|
+
"model_id",
|
|
3105
|
+
"stream_type",
|
|
3106
|
+
"error_message"
|
|
3107
|
+
]
|
|
3108
|
+
}, options);
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
//#endregion
|
|
3112
|
+
//#region src/shared/emitters/ai/events/tool.ts
|
|
3113
|
+
/**
|
|
3114
|
+
* @fileoverview Tool-related AI SDK v6 events
|
|
3115
|
+
* Tool-related AI SDK v6 events
|
|
3116
|
+
*/
|
|
3117
|
+
/**
|
|
3118
|
+
* Track when a tool call starts
|
|
3119
|
+
*/
|
|
3120
|
+
function toolCallStarted(properties, options) {
|
|
3121
|
+
validateRequiredProperties(properties, ["model_id", "tool_name"]);
|
|
3122
|
+
const normalizedProps = {
|
|
3123
|
+
...normalizeBaseProperties(properties),
|
|
3124
|
+
tool_name: properties.tool_name,
|
|
3125
|
+
tool_type: properties.tool_type,
|
|
3126
|
+
input_size: properties.input_size
|
|
3127
|
+
};
|
|
3128
|
+
return trackAISDK({
|
|
3129
|
+
name: AI_SDK_EVENTS.TOOL_CALL_STARTED,
|
|
3130
|
+
category: "ai-sdk",
|
|
3131
|
+
properties: cleanProperties(normalizedProps),
|
|
3132
|
+
requiredProperties: ["model_id", "tool_name"]
|
|
3133
|
+
}, options);
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Track when a tool call completes successfully
|
|
3137
|
+
*/
|
|
3138
|
+
function toolCallCompleted(properties, options) {
|
|
3139
|
+
validateRequiredProperties(properties, [
|
|
3140
|
+
"model_id",
|
|
3141
|
+
"tool_name",
|
|
3142
|
+
"result_status"
|
|
3143
|
+
]);
|
|
3144
|
+
const normalizedProps = {
|
|
3145
|
+
...normalizeBaseProperties(properties),
|
|
3146
|
+
tool_name: properties.tool_name,
|
|
3147
|
+
tool_type: properties.tool_type,
|
|
3148
|
+
result_status: properties.result_status,
|
|
3149
|
+
execution_time_ms: properties.execution_time_ms,
|
|
3150
|
+
input_size: properties.input_size,
|
|
3151
|
+
output_size: properties.output_size
|
|
3152
|
+
};
|
|
3153
|
+
return trackAISDK({
|
|
3154
|
+
name: AI_SDK_EVENTS.TOOL_CALL_COMPLETED,
|
|
3155
|
+
category: "ai-sdk",
|
|
3156
|
+
properties: cleanProperties(normalizedProps),
|
|
3157
|
+
requiredProperties: [
|
|
3158
|
+
"model_id",
|
|
3159
|
+
"tool_name",
|
|
3160
|
+
"result_status"
|
|
3161
|
+
]
|
|
3162
|
+
}, options);
|
|
3163
|
+
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Track when a tool call fails
|
|
3166
|
+
*/
|
|
3167
|
+
function toolCallFailed(properties, options) {
|
|
3168
|
+
validateRequiredProperties(properties, [
|
|
3169
|
+
"model_id",
|
|
3170
|
+
"tool_name",
|
|
3171
|
+
"error_message"
|
|
3172
|
+
]);
|
|
3173
|
+
const normalizedProps = {
|
|
3174
|
+
...normalizeBaseProperties(properties),
|
|
3175
|
+
tool_name: properties.tool_name,
|
|
3176
|
+
tool_type: properties.tool_type,
|
|
3177
|
+
result_status: "error",
|
|
3178
|
+
error_message: properties.error_message,
|
|
3179
|
+
execution_time_ms: properties.execution_time_ms
|
|
3180
|
+
};
|
|
3181
|
+
return trackAISDK({
|
|
3182
|
+
name: AI_SDK_EVENTS.TOOL_CALL_FAILED,
|
|
3183
|
+
category: "ai-sdk",
|
|
3184
|
+
properties: cleanProperties(normalizedProps),
|
|
3185
|
+
requiredProperties: [
|
|
3186
|
+
"model_id",
|
|
3187
|
+
"tool_name",
|
|
3188
|
+
"error_message"
|
|
3189
|
+
]
|
|
3190
|
+
}, options);
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
//#endregion
|
|
3194
|
+
//#region src/shared/emitters/ai/index.ts
|
|
3195
|
+
var ai_exports = /* @__PURE__ */ __exportAll({
|
|
3196
|
+
AI_EVENTS: () => AI_EVENTS,
|
|
3197
|
+
AI_SDK_EVENTS: () => AI_SDK_EVENTS,
|
|
3198
|
+
API_REQUEST_MADE: () => API_REQUEST_MADE,
|
|
3199
|
+
ARTIFACT_CREATED: () => ARTIFACT_CREATED,
|
|
3200
|
+
ARTIFACT_EDITED: () => ARTIFACT_EDITED,
|
|
3201
|
+
ARTIFACT_EXECUTED: () => ARTIFACT_EXECUTED,
|
|
3202
|
+
ARTIFACT_FORKED: () => ARTIFACT_FORKED,
|
|
3203
|
+
ARTIFACT_PUBLISHED: () => ARTIFACT_PUBLISHED,
|
|
3204
|
+
BATCH_FILES_PROCESSED: () => BATCH_FILES_PROCESSED,
|
|
3205
|
+
BRANCH_CREATED: () => BRANCH_CREATED,
|
|
3206
|
+
BRANCH_MERGED: () => BRANCH_MERGED,
|
|
3207
|
+
BROWSE_SESSION_STARTED: () => BROWSE_SESSION_STARTED,
|
|
3208
|
+
BUG_REPORTED: () => BUG_REPORTED,
|
|
3209
|
+
CANVAS_OPENED: () => CANVAS_OPENED,
|
|
3210
|
+
CITATION_ADDED: () => CITATION_ADDED,
|
|
3211
|
+
CODE_COPIED: () => CODE_COPIED,
|
|
3212
|
+
CODE_DEBUGGED: () => CODE_DEBUGGED,
|
|
3213
|
+
CODE_EXECUTED: () => CODE_EXECUTED,
|
|
3214
|
+
CODE_EXPLAINED: () => CODE_EXPLAINED,
|
|
3215
|
+
CODE_GENERATED: () => CODE_GENERATED,
|
|
3216
|
+
CODE_REFACTORED: () => CODE_REFACTORED,
|
|
3217
|
+
CODE_TRANSLATED: () => CODE_TRANSLATED,
|
|
3218
|
+
COMMENT_ADDED: () => COMMENT_ADDED,
|
|
3219
|
+
COMPLETION_GENERATED: () => COMPLETION_GENERATED,
|
|
3220
|
+
CONTENT_COPIED: () => CONTENT_COPIED,
|
|
3221
|
+
CONTENT_DOWNLOADED: () => CONTENT_DOWNLOADED,
|
|
3222
|
+
CONTENT_SHARED: () => CONTENT_SHARED,
|
|
3223
|
+
CONTEXT_WINDOW_UPDATED: () => CONTEXT_WINDOW_UPDATED,
|
|
3224
|
+
CONVERSATION_ARCHIVED: () => CONVERSATION_ARCHIVED,
|
|
3225
|
+
CONVERSATION_DELETED: () => CONVERSATION_DELETED,
|
|
3226
|
+
CONVERSATION_ENDED: () => CONVERSATION_ENDED,
|
|
3227
|
+
CONVERSATION_FORKED: () => CONVERSATION_FORKED,
|
|
3228
|
+
CONVERSATION_RENAMED: () => CONVERSATION_RENAMED,
|
|
3229
|
+
CONVERSATION_RESUMED: () => CONVERSATION_RESUMED,
|
|
3230
|
+
CONVERSATION_SHARED: () => CONVERSATION_SHARED,
|
|
3231
|
+
CONVERSATION_STARTED: () => CONVERSATION_STARTED,
|
|
3232
|
+
CUSTOM_INSTRUCTIONS_UPDATED: () => CUSTOM_INSTRUCTIONS_UPDATED,
|
|
3233
|
+
DIFF_VIEWED: () => DIFF_VIEWED,
|
|
3234
|
+
DOCUMENT_CREATED: () => DOCUMENT_CREATED,
|
|
3235
|
+
EMAIL_DRAFTED: () => EMAIL_DRAFTED,
|
|
3236
|
+
EMBEDDING_GENERATED: () => EMBEDDING_GENERATED,
|
|
3237
|
+
ERROR_OCCURRED: () => ERROR_OCCURRED,
|
|
3238
|
+
EXTENSION_USED: () => EXTENSION_USED,
|
|
3239
|
+
EXTERNAL_SOURCE_ACCESSED: () => EXTERNAL_SOURCE_ACCESSED,
|
|
3240
|
+
FEATURE_REQUESTED: () => FEATURE_REQUESTED,
|
|
3241
|
+
FEEDBACK_PROVIDED: () => FEEDBACK_PROVIDED,
|
|
3242
|
+
FILE_DELETED: () => FILE_DELETED,
|
|
3243
|
+
FILE_DOWNLOADED: () => FILE_DOWNLOADED,
|
|
3244
|
+
FILE_PROCESSED: () => FILE_PROCESSED,
|
|
3245
|
+
FILE_PROCESSING_FAILED: () => FILE_PROCESSING_FAILED,
|
|
3246
|
+
FILE_REFERENCED: () => FILE_REFERENCED,
|
|
3247
|
+
FILE_UPLOADED: () => FILE_UPLOADED,
|
|
3248
|
+
FILTER_APPLIED: () => FILTER_APPLIED,
|
|
3249
|
+
FOLDER_CREATED: () => FOLDER_CREATED,
|
|
3250
|
+
FUNCTION_EXECUTED: () => FUNCTION_EXECUTED,
|
|
3251
|
+
HARMFUL_CONTENT_FLAGGED: () => HARMFUL_CONTENT_FLAGGED,
|
|
3252
|
+
IMAGE_EDITED: () => IMAGE_EDITED,
|
|
3253
|
+
IMAGE_GENERATED: () => IMAGE_GENERATED,
|
|
3254
|
+
INLINE_EDIT_APPLIED: () => INLINE_EDIT_APPLIED,
|
|
3255
|
+
KNOWLEDGE_BASE_QUERIED: () => KNOWLEDGE_BASE_QUERIED,
|
|
3256
|
+
LIVE_PREVIEW_TOGGLED: () => LIVE_PREVIEW_TOGGLED,
|
|
3257
|
+
MAX_PRODUCT_IDS: () => MAX_PRODUCT_IDS,
|
|
3258
|
+
MEMBER_INVITED: () => MEMBER_INVITED,
|
|
3259
|
+
MEMORY_CREATED: () => MEMORY_CREATED,
|
|
3260
|
+
MEMORY_DELETED: () => MEMORY_DELETED,
|
|
3261
|
+
MEMORY_RETRIEVED: () => MEMORY_RETRIEVED,
|
|
3262
|
+
MEMORY_UPDATED: () => MEMORY_UPDATED,
|
|
3263
|
+
MESSAGE_DELETED: () => MESSAGE_DELETED,
|
|
3264
|
+
MESSAGE_EDITED: () => MESSAGE_EDITED,
|
|
3265
|
+
MESSAGE_RECEIVED: () => MESSAGE_RECEIVED,
|
|
3266
|
+
MESSAGE_REGENERATED: () => MESSAGE_REGENERATED,
|
|
3267
|
+
MESSAGE_SENT: () => MESSAGE_SENT,
|
|
3268
|
+
MODEL_SWITCHED: () => MODEL_SWITCHED,
|
|
3269
|
+
OUTLINE_CREATED: () => OUTLINE_CREATED,
|
|
3270
|
+
PAGE_CONTENT_FETCHED: () => PAGE_CONTENT_FETCHED,
|
|
3271
|
+
PERFORMANCE_MEASURED: () => PERFORMANCE_MEASURED,
|
|
3272
|
+
PERMISSION_CHANGED: () => PERMISSION_CHANGED,
|
|
3273
|
+
PLUGIN_ACTIVATED: () => PLUGIN_ACTIVATED,
|
|
3274
|
+
PROJECT_CONTEXT_LOADED: () => PROJECT_CONTEXT_LOADED,
|
|
3275
|
+
QUALITY_ISSUE_REPORTED: () => QUALITY_ISSUE_REPORTED,
|
|
3276
|
+
RAG_QUERY_EXECUTED: () => RAG_QUERY_EXECUTED,
|
|
3277
|
+
RATE_LIMIT_HIT: () => RATE_LIMIT_HIT,
|
|
3278
|
+
RESPONSE_RATED: () => RESPONSE_RATED,
|
|
3279
|
+
REWRITE_GENERATED: () => REWRITE_GENERATED,
|
|
3280
|
+
SEARCH_PERFORMED: () => SEARCH_PERFORMED,
|
|
3281
|
+
SEARCH_RESULTS_RANKED: () => SEARCH_RESULTS_RANKED,
|
|
3282
|
+
SETTINGS_UPDATED: () => SETTINGS_UPDATED,
|
|
3283
|
+
STOP_GENERATION: () => STOP_GENERATION,
|
|
3284
|
+
STREAMING_CHUNK_RECEIVED: () => STREAMING_CHUNK_RECEIVED,
|
|
3285
|
+
STREAMING_COMPLETED: () => STREAMING_COMPLETED,
|
|
3286
|
+
STREAMING_STARTED: () => STREAMING_STARTED,
|
|
3287
|
+
SUGGESTION_ACCEPTED: () => SUGGESTION_ACCEPTED,
|
|
3288
|
+
SUGGESTION_REJECTED: () => SUGGESTION_REJECTED,
|
|
3289
|
+
SUMMARY_GENERATED: () => SUMMARY_GENERATED,
|
|
3290
|
+
TAG_ADDED: () => TAG_ADDED,
|
|
3291
|
+
TEXT_GENERATED: () => TEXT_GENERATED,
|
|
3292
|
+
TOKEN_USAGE_TRACKED: () => TOKEN_USAGE_TRACKED,
|
|
3293
|
+
TOOL_CALL_COMPLETED: () => TOOL_CALL_COMPLETED,
|
|
3294
|
+
TOOL_CALL_FAILED: () => TOOL_CALL_FAILED,
|
|
3295
|
+
TOOL_CALL_STARTED: () => TOOL_CALL_STARTED,
|
|
3296
|
+
TRANSLATION_GENERATED: () => TRANSLATION_GENERATED,
|
|
3297
|
+
WEB_SEARCH_PERFORMED: () => WEB_SEARCH_PERFORMED,
|
|
3298
|
+
WORKSPACE_CREATED: () => WORKSPACE_CREATED,
|
|
3299
|
+
agentCreated: () => agentCreated,
|
|
3300
|
+
agentExecutionCompleted: () => agentExecutionCompleted,
|
|
3301
|
+
agentExecutionFailed: () => agentExecutionFailed,
|
|
3302
|
+
agentExecutionStarted: () => agentExecutionStarted,
|
|
3303
|
+
calculateCompletionMetrics: () => calculateCompletionMetrics,
|
|
3304
|
+
calculateCost: () => calculateCost,
|
|
3305
|
+
calculateQualityScore: () => calculateQualityScore,
|
|
3306
|
+
chatMessageReceived: () => chatMessageReceived,
|
|
3307
|
+
chatMessageSent: () => chatMessageSent,
|
|
3308
|
+
chatSessionEnded: () => chatSessionEnded,
|
|
3309
|
+
chatSessionStarted: () => chatSessionStarted,
|
|
3310
|
+
chatbotCartAssisted: () => chatbotCartAssisted,
|
|
3311
|
+
chatbotIntentDetected: () => chatbotIntentDetected,
|
|
3312
|
+
chatbotOrderAssisted: () => chatbotOrderAssisted,
|
|
3313
|
+
chatbotProductRecommended: () => chatbotProductRecommended,
|
|
3314
|
+
cleanProperties: () => cleanProperties,
|
|
3315
|
+
completionFailed: () => completionFailed,
|
|
3316
|
+
completionGenerated: () => completionGenerated,
|
|
3317
|
+
completionRequested: () => completionRequested,
|
|
3318
|
+
createAISDKTracker: () => createAISDKTracker,
|
|
3319
|
+
createAITracker: () => createAITracker,
|
|
3320
|
+
detectChatbotIntent: () => detectChatbotIntent,
|
|
3321
|
+
detectIntent: () => detectIntent,
|
|
3322
|
+
detectSentiment: () => detectSentiment,
|
|
3323
|
+
extractModelProvider: () => extractModelProvider,
|
|
3324
|
+
extractProductMentions: () => extractProductMentions,
|
|
3325
|
+
generateOperationId: () => generateOperationId,
|
|
3326
|
+
needsClarification: () => needsClarification,
|
|
3327
|
+
normalizeBaseProperties: () => normalizeBaseProperties,
|
|
3328
|
+
normalizeModelConfig: () => normalizeModelConfig,
|
|
3329
|
+
normalizeTokenUsage: () => normalizeTokenUsage,
|
|
3330
|
+
safeStringify: () => safeStringify,
|
|
3331
|
+
sanitizeErrorMessage: () => sanitizeErrorMessage,
|
|
3332
|
+
streamChunkReceived: () => streamChunkReceived,
|
|
3333
|
+
streamCompleted: () => streamCompleted,
|
|
3334
|
+
streamFailed: () => streamFailed,
|
|
3335
|
+
streamStarted: () => streamStarted,
|
|
3336
|
+
toolCallCompleted: () => toolCallCompleted,
|
|
3337
|
+
toolCallFailed: () => toolCallFailed,
|
|
3338
|
+
toolCallStarted: () => toolCallStarted,
|
|
3339
|
+
trackAI: () => trackAI,
|
|
3340
|
+
trackAISDK: () => trackAISDK,
|
|
3341
|
+
truncateArray: () => truncateArray,
|
|
3342
|
+
validateRequiredProperties: () => validateRequiredProperties
|
|
3343
|
+
});
|
|
3344
|
+
|
|
3345
|
+
//#endregion
|
|
3346
|
+
export { ai_exports as t };
|
|
3347
|
+
//# sourceMappingURL=ai-YMnynb-t.mjs.map
|