Skip to content

Commit

Permalink
Remove PostHog event calls
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Aug 11, 2023
1 parent 78c8316 commit b96fbbd
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
15 changes: 11 additions & 4 deletions packages/editor-ui/src/plugins/telemetry/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { Plugin } from 'vue';
import type { ITelemetrySettings, ITelemetryTrackProperties, IDataObject } from 'n8n-workflow';
import type {
ITelemetrySettings,
ITelemetryTrackProperties,
IDataObject,
Integrations,
} from 'n8n-workflow';
import type { RouteLocation } from 'vue-router';

import type { INodeCreateElement, IUpdateInformation } from '@/Interface';
Expand Down Expand Up @@ -79,15 +84,17 @@ export class Telemetry {
}
}

track(event: string, properties?: ITelemetryTrackProperties) {
track(event: string, properties?: ITelemetryTrackProperties, integrations: Integrations = {}) {
if (!this.rudderStack) return;

const updatedProperties = {
...properties,
version_cli: useRootStore().versionCli,
};

this.rudderStack.track(event, updatedProperties);
this.rudderStack.track(event, updatedProperties, {
integrations: { PostHog: false, ...integrations },
});
}

page(route: Route) {
Expand Down Expand Up @@ -187,7 +194,7 @@ export class Telemetry {
this.track('User viewed node category', properties);
break;
case 'nodeView.addNodeButton':
this.track('User added node to workflow canvas', properties);
this.track('User added node to workflow canvas', properties, { PostHog: true });
break;
case 'nodeView.addSticky':
this.track('User inserted workflow note', properties);
Expand Down
12 changes: 8 additions & 4 deletions packages/editor-ui/src/stores/posthog.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ export const usePostHog = defineStore('posthog', () => {
return;
}

telemetryStore.track(EVENTS.IS_PART_OF_EXPERIMENT, {
name,
variant,
});
telemetryStore.track(
EVENTS.IS_PART_OF_EXPERIMENT,
{
name,
variant,
},
{ PostHog: true },
);

trackedDemoExp.value[name] = variant;
};
Expand Down
10 changes: 7 additions & 3 deletions packages/editor-ui/src/stores/telemetry.store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Telemetry } from '@/plugins/telemetry';
import type { ITelemetryTrackProperties } from 'n8n-workflow';
import type { ITelemetryTrackProperties, Integrations } from 'n8n-workflow';
import { defineStore } from 'pinia';
import type { Ref } from 'vue';
import { ref } from 'vue';
Expand All @@ -11,8 +11,12 @@ export const useTelemetryStore = defineStore('telemetry', () => {
telemetry.value = tel;
};

const track = (event: string, properties?: ITelemetryTrackProperties) => {
telemetry.value?.track(event, properties);
const track = (
event: string,
properties?: ITelemetryTrackProperties,
integrations: Integrations = {},
) => {
telemetry.value?.track(event, properties, integrations);
};

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/TemplatesCollectionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default defineComponent({
source: 'collection',
};
void this.$externalHooks().run('templatesCollectionView.onUseWorkflow', telemetryPayload);
this.$telemetry.track('User inserted workflow template', telemetryPayload);
this.$telemetry.track('User inserted workflow template', telemetryPayload, { PostHog: true });
this.navigateTo(event, VIEWS.TEMPLATE_IMPORT, id);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/TemplatesWorkflowView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default defineComponent({
};
void this.$externalHooks().run('templatesWorkflowView.openWorkflow', telemetryPayload);
this.$telemetry.track('User inserted workflow template', telemetryPayload);
this.$telemetry.track('User inserted workflow template', telemetryPayload, { PostHog: true });
if (e.metaKey || e.ctrlKey) {
const route = this.$router.resolve({ name: VIEWS.TEMPLATE_IMPORT, params: { id } });
Expand Down
2 changes: 2 additions & 0 deletions packages/workflow/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,8 @@ export interface ITelemetryTrackProperties {
[key: string]: GenericValue;
}

export type Integrations = Record<'PostHog', boolean> | {};

export interface INodesGraph {
node_types: string[];
node_connections: IDataObject[];
Expand Down

0 comments on commit b96fbbd

Please sign in to comment.