Skip to content

Commit

Permalink
fix(editor): Sending 'Assistant session started event' to posthog (no…
Browse files Browse the repository at this point in the history
…-changelog) (#10500)

Co-authored-by: Shireen Missi <[email protected]>
  • Loading branch information
MiloradFilipovic and ShireenMissi authored Aug 21, 2024
1 parent 547a606 commit 0276323
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ const lastUnread = computed(() => {
const onClick = () => {
assistantStore.openChat();
telemetry.track(
'User opened assistant',
{
source: 'canvas',
task: 'placeholder',
has_existing_session: !assistantStore.isSessionEnded,
workflow_id: workflowStore.workflowId,
},
{ withPostHog: true },
);
telemetry.track('User opened assistant', {
source: 'canvas',
task: 'placeholder',
has_existing_session: !assistantStore.isSessionEnded,
workflow_id: workflowStore.workflowId,
});
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@ const close = () => {
const startNewSession = async () => {
await assistantStore.initErrorHelper(props.data.context);
telemetry.track(
'User opened assistant',
{
source: 'error',
task: 'error',
has_existing_session: true,
workflow_id: workflowsStore.workflowId,
node_type: props.data.context.node.type,
error: props.data.context.error,
chat_session_id: assistantStore.currentSessionId,
},
{ withPostHog: true },
);
telemetry.track('User opened assistant', {
source: 'error',
task: 'error',
has_existing_session: true,
workflow_id: workflowsStore.workflowId,
node_type: props.data.context.node.type,
error: props.data.context.error,
chat_session_id: assistantStore.currentSessionId,
});
close();
};
</script>
Expand Down
20 changes: 8 additions & 12 deletions packages/editor-ui/src/components/Error/NodeErrorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,14 @@ async function onAskAssistantClick() {
return;
}
await assistantStore.initErrorHelper(errorPayload);
telemetry.track(
'User opened assistant',
{
source: 'error',
task: 'error',
has_existing_session: false,
workflow_id: workflowsStore.workflowId,
node_type: node.value.type,
error: props.error,
},
{ withPostHog: true },
);
telemetry.track('User opened assistant', {
source: 'error',
task: 'error',
has_existing_session: false,
workflow_id: workflowsStore.workflowId,
node_type: node.value.type,
error: props.error,
});
}
</script>

Expand Down
12 changes: 8 additions & 4 deletions packages/editor-ui/src/stores/assistant.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,14 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
function onEachStreamingMessage(response: ChatRequest.ResponsePayload, id: string) {
if (response.sessionId && !currentSessionId.value) {
currentSessionId.value = response.sessionId;
telemetry.track('Assistant session started', {
chat_session_id: currentSessionId.value,
task: 'error',
});
telemetry.track(
'Assistant session started',
{
chat_session_id: currentSessionId.value,
task: 'error',
},
{ withPostHog: true },
);
} else if (currentSessionId.value !== response.sessionId) {
return;
}
Expand Down

0 comments on commit 0276323

Please sign in to comment.