fix(editor): Sending 'Assistant session started event' to posthog (no-changelog) (#10500)

Co-authored-by: Shireen Missi <shireen@n8n.io>
This commit is contained in:
Milorad FIlipović
2024-08-21 17:31:02 +02:00
committed by GitHub
parent 547a60642c
commit 0276323881
4 changed files with 31 additions and 39 deletions

View File

@@ -28,16 +28,12 @@ const lastUnread = computed(() => {
const onClick = () => { const onClick = () => {
assistantStore.openChat(); assistantStore.openChat();
telemetry.track( telemetry.track('User opened assistant', {
'User opened assistant', source: 'canvas',
{ task: 'placeholder',
source: 'canvas', has_existing_session: !assistantStore.isSessionEnded,
task: 'placeholder', workflow_id: workflowStore.workflowId,
has_existing_session: !assistantStore.isSessionEnded, });
workflow_id: workflowStore.workflowId,
},
{ withPostHog: true },
);
}; };
</script> </script>

View File

@@ -29,19 +29,15 @@ const close = () => {
const startNewSession = async () => { const startNewSession = async () => {
await assistantStore.initErrorHelper(props.data.context); await assistantStore.initErrorHelper(props.data.context);
telemetry.track( telemetry.track('User opened assistant', {
'User opened assistant', source: 'error',
{ task: 'error',
source: 'error', has_existing_session: true,
task: 'error', workflow_id: workflowsStore.workflowId,
has_existing_session: true, node_type: props.data.context.node.type,
workflow_id: workflowsStore.workflowId, error: props.data.context.error,
node_type: props.data.context.node.type, chat_session_id: assistantStore.currentSessionId,
error: props.data.context.error, });
chat_session_id: assistantStore.currentSessionId,
},
{ withPostHog: true },
);
close(); close();
}; };
</script> </script>

View File

@@ -433,18 +433,14 @@ async function onAskAssistantClick() {
return; return;
} }
await assistantStore.initErrorHelper(errorPayload); await assistantStore.initErrorHelper(errorPayload);
telemetry.track( telemetry.track('User opened assistant', {
'User opened assistant', source: 'error',
{ task: 'error',
source: 'error', has_existing_session: false,
task: 'error', workflow_id: workflowsStore.workflowId,
has_existing_session: false, node_type: node.value.type,
workflow_id: workflowsStore.workflowId, error: props.error,
node_type: node.value.type, });
error: props.error,
},
{ withPostHog: true },
);
} }
</script> </script>

View File

@@ -245,10 +245,14 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
function onEachStreamingMessage(response: ChatRequest.ResponsePayload, id: string) { function onEachStreamingMessage(response: ChatRequest.ResponsePayload, id: string) {
if (response.sessionId && !currentSessionId.value) { if (response.sessionId && !currentSessionId.value) {
currentSessionId.value = response.sessionId; currentSessionId.value = response.sessionId;
telemetry.track('Assistant session started', { telemetry.track(
chat_session_id: currentSessionId.value, 'Assistant session started',
task: 'error', {
}); chat_session_id: currentSessionId.value,
task: 'error',
},
{ withPostHog: true },
);
} else if (currentSessionId.value !== response.sessionId) { } else if (currentSessionId.value !== response.sessionId) {
return; return;
} }