mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(editor): Fix sending of Ask AI tracking events (#7002)
This commit is contained in:
parent
92d4befea6
commit
fb05afa165
|
@ -170,28 +170,12 @@ async function onSubmit() {
|
|||
type: 'success',
|
||||
title: i18n.baseText('codeNodeEditor.askAi.generationCompleted'),
|
||||
});
|
||||
|
||||
useTelemetry().trackAskAI('askAi.generationFinished', {
|
||||
prompt: prompt.value,
|
||||
code,
|
||||
tokensCount: usage?.total_tokens,
|
||||
hasErrors: false,
|
||||
error: '',
|
||||
});
|
||||
} catch (error) {
|
||||
showMessage({
|
||||
type: 'error',
|
||||
title: i18n.baseText('codeNodeEditor.askAi.generationFailed'),
|
||||
message: getErrorMessageByStatusCode(error.httpStatusCode || error?.response.status),
|
||||
});
|
||||
|
||||
useTelemetry().trackAskAI('askAi.generationFinished', {
|
||||
prompt: prompt.value,
|
||||
code: '',
|
||||
tokensCount: 0,
|
||||
hasErrors: true,
|
||||
error: getErrorMessageByStatusCode(error.httpStatusCode || error?.response.status),
|
||||
});
|
||||
stopLoading();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { usePostHog } from '@/stores/posthog.store';
|
|||
|
||||
export class Telemetry {
|
||||
private pageEventQueue: Array<{ route: RouteLocation }>;
|
||||
|
||||
private previousPath: string;
|
||||
|
||||
private get rudderStack() {
|
||||
|
@ -110,16 +111,15 @@ export class Telemetry {
|
|||
const pageName = route.name;
|
||||
let properties: { [key: string]: string } = {};
|
||||
if (
|
||||
route.meta &&
|
||||
route.meta.telemetry &&
|
||||
route.meta?.telemetry &&
|
||||
typeof route.meta.telemetry.getProperties === 'function'
|
||||
) {
|
||||
properties = route.meta.telemetry.getProperties(route);
|
||||
}
|
||||
|
||||
const category =
|
||||
(route.meta && route.meta.telemetry && route.meta.telemetry.pageCategory) || 'Editor';
|
||||
this.rudderStack.page(category, pageName!, properties);
|
||||
(route.meta?.telemetry?.pageCategory) || 'Editor';
|
||||
this.rudderStack.page(category, pageName, properties);
|
||||
} else {
|
||||
this.pageEventQueue.push({
|
||||
route,
|
||||
|
@ -139,10 +139,8 @@ export class Telemetry {
|
|||
if (this.rudderStack) {
|
||||
properties.session_id = useRootStore().sessionId;
|
||||
switch (event) {
|
||||
case 'askAi.generationFinished':
|
||||
this.track('Ai code generation finished', properties, { withPostHog: true });
|
||||
case 'ask.generationClicked':
|
||||
this.track('User clicked on generate code button', properties);
|
||||
this.track('User clicked on generate code button', properties, { withPostHog: true });
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue