diff --git a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts index 3701db8a8b..e6824e8342 100644 --- a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts +++ b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts @@ -33,6 +33,7 @@ vi.mock('@/composables/useI18n', () => ({ }), })); +const workflowPrompt = 'Create a workflow'; describe('AskAssistantBuild', () => { const sessionId = faker.string.uuid(); const renderComponent = createComponentRenderer(AskAssistantBuild); @@ -48,7 +49,7 @@ describe('AskAssistantBuild', () => { currentSessionId: sessionId, streaming: false, assistantThinkingMessage: undefined, - workflowPrompt: 'Create a workflow', + workflowPrompt, }, }, }); @@ -61,6 +62,7 @@ describe('AskAssistantBuild', () => { builderStore.resetBuilderChat = vi.fn(); builderStore.addAssistantMessages = vi.fn(); builderStore.$onAction = vi.fn().mockReturnValue(vi.fn()); + builderStore.workflowPrompt = workflowPrompt; }); describe('rendering', () => { @@ -99,6 +101,7 @@ describe('AskAssistantBuild', () => { }); describe('feedback handling', () => { + const workflowJson = '{"nodes": [], "connections": {}}'; beforeEach(() => { builderStore.chatMessages = [ { @@ -106,7 +109,7 @@ describe('AskAssistantBuild', () => { role: 'assistant', type: 'workflow-generated', read: true, - codeSnippet: '{}', + codeSnippet: workflowJson, }, { id: faker.string.uuid(), @@ -128,8 +131,9 @@ describe('AskAssistantBuild', () => { await flushPromises(); expect(trackMock).toHaveBeenCalledWith('User rated workflow generation', { - chat_session_id: sessionId, helpful: true, + prompt: 'Create a workflow', + workflow_json: workflowJson, }); }); @@ -143,8 +147,9 @@ describe('AskAssistantBuild', () => { await flushPromises(); expect(trackMock).toHaveBeenCalledWith('User rated workflow generation', { - chat_session_id: sessionId, helpful: false, + prompt: 'Create a workflow', + workflow_json: workflowJson, }); }); @@ -171,8 +176,9 @@ describe('AskAssistantBuild', () => { expect(trackMock).toHaveBeenCalledWith( 'User submitted workflow generation feedback', expect.objectContaining({ - chat_session_id: sessionId, feedback: feedbackText, + prompt: 'Create a workflow', + workflow_json: workflowJson, }), ); }); diff --git a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue index e0d04a7687..d912766547 100644 --- a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue +++ b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue @@ -28,6 +28,9 @@ const user = computed(() => ({ const workflowGenerated = ref(false); const loadingMessage = computed(() => builderStore.assistantThinkingMessage); +const generatedWorkflowJson = computed( + () => builderStore.chatMessages.find((msg) => msg.type === 'workflow-generated')?.codeSnippet, +); async function onUserMessage(content: string) { // If there is no current session running, initialize the support chat session @@ -84,7 +87,7 @@ function onInsertWorkflow(code: string) { telemetry.track('Workflow generated from prompt', { prompt: builderStore.workflowPrompt, latency: new Date().getTime() - generationStartTime.value, - workflow_json: code, + workflow_json: generatedWorkflowJson.value, }); nodeViewEventBus.emit('importWorkflowData', { @@ -114,24 +117,27 @@ function onNewWorkflow() { function onThumbsUp() { helpful.value = true; telemetry.track('User rated workflow generation', { - chat_session_id: builderStore.currentSessionId, helpful: helpful.value, + prompt: builderStore.workflowPrompt, + workflow_json: generatedWorkflowJson.value, }); } function onThumbsDown() { helpful.value = false; telemetry.track('User rated workflow generation', { - chat_session_id: builderStore.currentSessionId, helpful: helpful.value, + prompt: builderStore.workflowPrompt, + workflow_json: generatedWorkflowJson.value, }); } function onSubmitFeedback(feedback: string) { telemetry.track('User submitted workflow generation feedback', { - chat_session_id: builderStore.currentSessionId, helpful: helpful.value, feedback, + prompt: builderStore.workflowPrompt, + workflow_json: generatedWorkflowJson.value, }); }