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; openNDV?: boolean;
trackHistory?: boolean; trackHistory?: boolean;
isAutoAdd?: boolean; isAutoAdd?: boolean;
telemetry?: boolean;
}; };
export function useCanvasOperations({ router }: { router: ReturnType<typeof useRouter> }) { export function useCanvasOperations({ router }: { router: ReturnType<typeof useRouter> }) {
@ -434,6 +435,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
trackHistory?: boolean; trackHistory?: boolean;
trackBulk?: boolean; trackBulk?: boolean;
keepPristine?: boolean; keepPristine?: boolean;
telemetry?: boolean;
} = {}, } = {},
) { ) {
let insertPosition = options.position; let insertPosition = options.position;
@ -474,7 +476,6 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
...options, ...options,
openNDV, openNDV,
isAutoAdd, isAutoAdd,
trackHistory: options.trackHistory,
}, },
); );
} catch (error) { } catch (error) {
@ -555,7 +556,13 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
createConnectionToLastInteractedWithNode(nodeData, options); 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) { if (options.openNDV && !preventOpeningNDV) {
ndvStore.setActiveNodeName(nodeData.name); 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) { switch (nodeData.type) {
case STICKY_NODE_TYPE: case STICKY_NODE_TYPE:
trackAddStickyNoteNode(); trackAddStickyNoteNode();
break; break;
default: default:
void externalHooks.run('nodeView.addNodeButton', { nodeTypeName: nodeData.type });
trackAddDefaultNode(nodeData, options); trackAddDefaultNode(nodeData, options);
} }
} }

View file

@ -809,7 +809,7 @@ async function onAddNodesAndConnections(
return; return;
} }
await addNodes(nodes, { dragAndDrop, position, trackHistory: true }); await addNodes(nodes, { dragAndDrop, position, trackHistory: true, telemetry: true });
await nextTick(); await nextTick();
const offsetIndex = editableWorkflow.value.nodes.length - nodes.length; const offsetIndex = editableWorkflow.value.nodes.length - nodes.length;