fix(editor): Fix sending of Ask AI tracking events (#7002)

This commit is contained in:
OlegIvaniv
2023-08-24 18:40:00 +02:00
committed by GitHub
parent 92d4befea6
commit fb05afa165
2 changed files with 5 additions and 23 deletions

View File

@@ -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;
}