From d44602913fa3d59fbd5cbeea9e8a4b0f60913afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 19 Dec 2023 12:23:30 +0100 Subject: [PATCH] refactor(editor): Add telemetry for debug in editor (no-changelog) (#8073) https://linear.app/n8n/issue/PAY-1142 --- packages/editor-ui/src/Interface.ts | 1 + .../src/composables/useExecutionDebugging.ts | 38 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index d5ca16ecc7..ccdabbacc6 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -373,6 +373,7 @@ export interface IExecutionPushResponse { export interface IExecutionResponse extends IExecutionBase { id: string; + status: string; data?: IRunExecutionData; workflowData: IWorkflowDb; executedNode?: string; diff --git a/packages/editor-ui/src/composables/useExecutionDebugging.ts b/packages/editor-ui/src/composables/useExecutionDebugging.ts index b62b9c69b7..b0f9a60cf9 100644 --- a/packages/editor-ui/src/composables/useExecutionDebugging.ts +++ b/packages/editor-ui/src/composables/useExecutionDebugging.ts @@ -13,8 +13,12 @@ import type { INodeUi } from '@/Interface'; import { useWorkflowsStore } from '@/stores/workflows.store'; import { useSettingsStore } from '@/stores/settings.store'; import { useUIStore } from '@/stores/ui.store'; +import { useTelemetry } from './useTelemetry'; +import { useRootStore } from '@/stores/n8nRoot.store'; export const useExecutionDebugging = () => { + const telemetry = useTelemetry(); + const router = useRouter(); const i18n = useI18n(); const message = useMessage(); @@ -92,17 +96,22 @@ export const useExecutionDebugging = () => { workflowsStore.setWorkflowExecutionData(execution); // Pin data of all nodes which do not have a parent node - workflowNodes - .filter((node: INodeUi) => !workflow.getParentNodes(node.name).length) - .forEach((node: INodeUi) => { - const nodeData = runData[node.name]?.[0].data?.main[0]; - if (nodeData) { - workflowsStore.pinData({ - node, - data: nodeData, - }); - } - }); + const pinnableNodes = workflowNodes.filter( + (node: INodeUi) => !workflow.getParentNodes(node.name).length, + ); + + let pinnings = 0; + + pinnableNodes.forEach((node: INodeUi) => { + const nodeData = runData[node.name]?.[0].data?.main[0]; + if (nodeData) { + pinnings++; + workflowsStore.pinData({ + node, + data: nodeData, + }); + } + }); toast.showToast({ title: i18n.baseText('nodeView.showMessage.debug.title'), @@ -119,6 +128,13 @@ export const useExecutionDebugging = () => { type: 'warning', }); } + + telemetry.track('User clicked debug execution button', { + instance_id: useRootStore().instanceId, + exec_status: execution.status, + override_pinned_data: pinnableNodes.length === pinnings, + all_exec_data_imported: missingNodeNames.length === 0, + }); }; const handleDebugLinkClick = (event: Event): void => {