fix(editor): Stop telemetry from triggering when initializing workflow in new canvas (no-changelog) (#10492)

This commit is contained in:
Alex Grozav 2024-08-21 15:46:36 +03:00 committed by GitHub
parent d4012c7bf8
commit d5acde5ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -105,6 +105,7 @@ type AddNodeOptions = {
openNDV?: boolean;
trackHistory?: boolean;
isAutoAdd?: boolean;
telemetry?: boolean;
};
export function useCanvasOperations({ router }: { router: ReturnType<typeof useRouter> }) {
@ -434,6 +435,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
trackHistory?: boolean;
trackBulk?: boolean;
keepPristine?: boolean;
telemetry?: boolean;
} = {},
) {
let insertPosition = options.position;
@ -474,7 +476,6 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
...options,
openNDV,
isAutoAdd,
trackHistory: options.trackHistory,
},
);
} catch (error) {
@ -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);
@ -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);
}
}

View file

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