The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Split onboarding chat spans into their own telemetry functionId (#24353)
Raphaël Bosi0b03ea0e20bb
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-stream-function-id.constant.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-stream-function-id.constant.tsnew file mode 100644index 00000000000..2a517a23950--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-stream-function-id.constant.ts@@ -0,0 +1 @@+export const AI_CHAT_STREAM_FUNCTION_ID = 'ai-chat-stream';diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-workspace-setup-stream-function-id.constant.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-workspace-setup-stream-function-id.constant.tsnew file mode 100644index 00000000000..99a865893ba--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-workspace-setup-stream-function-id.constant.ts@@ -0,0 +1,2 @@+export const AI_CHAT_WORKSPACE_SETUP_STREAM_FUNCTION_ID =+ 'ai-chat-workspace-setup-stream';diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/chat-execution.service.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/chat-execution.service.tsindex 091df179e96..99af3b19226 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/chat-execution.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/chat-execution.service.ts@@ -55,7 +55,9 @@ import {extractCacheCreationTokens,extractCacheCreationTokensFromSteps,} from 'src/engine/metadata-modules/ai/ai-billing/utils/extract-cache-creation-tokens.util';+import { AI_CHAT_STREAM_FUNCTION_ID } from 'src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-stream-function-id.constant';import { AI_CHAT_TOOL_NAMES_TO_PRELOAD } from 'src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-tool-names-to-preload.const';+import { AI_CHAT_WORKSPACE_SETUP_STREAM_FUNCTION_ID } from 'src/engine/metadata-modules/ai/ai-chat/constants/ai-chat-workspace-setup-stream-function-id.constant';import { MessagePruningService } from 'src/engine/metadata-modules/ai/ai-chat/services/message-pruning.service';import { SystemPromptBuilderService } from 'src/engine/metadata-modules/ai/ai-chat/services/system-prompt-builder.service';import {@@ -471,7 +473,9 @@ export class ChatExecutionService {hasToolCall(COMPLETE_WORKSPACE_SETUP_TOOL_NAME)(step) ||hasNoMoreAvailableCredits,experimental_telemetry: buildAiTelemetry({- functionId: 'ai-chat-stream',+ functionId: isWorkspaceSetupThread+ ? AI_CHAT_WORKSPACE_SETUP_STREAM_FUNCTION_ID+ : AI_CHAT_STREAM_FUNCTION_ID,workspaceId: workspace.id,userWorkspaceId,threadId,