Skip to content

Commit

Permalink
fix(editor): Stop telemetry from triggering when initializing workflo…
Browse files Browse the repository at this point in the history
…w in new canvas (no-changelog) (#10492)
  • Loading branch information
alexgrozav authored Aug 21, 2024
1 parent d4012c7 commit d5acde5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions packages/editor-ui/src/composables/useCanvasOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type AddNodeOptions = {
openNDV?: boolean;
trackHistory?: boolean;
isAutoAdd?: boolean;
telemetry?: boolean;
};

export function useCanvasOperations({ router }: { router: ReturnType<typeof useRouter> }) {
Expand Down Expand Up @@ -434,6 +435,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
trackHistory?: boolean;
trackBulk?: boolean;
keepPristine?: boolean;
telemetry?: boolean;
} = {},
) {
let insertPosition = options.position;
Expand Down Expand Up @@ -474,7 +476,6 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
...options,
openNDV,
isAutoAdd,
trackHistory: options.trackHistory,
},
);
} catch (error) {
Expand Down Expand Up @@ -555,7 +556,13 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
createConnectionToLastInteractedWithNode(nodeData, options);
}

runAddNodeHooks(nodeData, options);
if (options.telemetry) {
trackAddNode(nodeData, options);
}

if (nodeData.type !== STICKY_NODE_TYPE) {
void externalHooks.run('nodeView.addNodeButton', { nodeTypeName: nodeData.type });
}

if (options.openNDV && !preventOpeningNDV) {
ndvStore.setActiveNodeName(nodeData.name);
Expand Down Expand Up @@ -652,13 +659,12 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
}
}

function runAddNodeHooks(nodeData: INodeUi, options: AddNodeOptions) {
function trackAddNode(nodeData: INodeUi, options: AddNodeOptions) {
switch (nodeData.type) {
case STICKY_NODE_TYPE:
trackAddStickyNoteNode();
break;
default:
void externalHooks.run('nodeView.addNodeButton', { nodeTypeName: nodeData.type });
trackAddDefaultNode(nodeData, options);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ async function onAddNodesAndConnections(
return;
}
await addNodes(nodes, { dragAndDrop, position, trackHistory: true });
await addNodes(nodes, { dragAndDrop, position, trackHistory: true, telemetry: true });
await nextTick();
const offsetIndex = editableWorkflow.value.nodes.length - nodes.length;
Expand Down

0 comments on commit d5acde5

Please sign in to comment.