Skip to content

Commit

Permalink
add node_graph_string in User clicked execute workflow button event
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsanv committed Jun 24, 2022
1 parent d0c39ce commit 3797c73
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
15 changes: 10 additions & 5 deletions packages/editor-ui/src/components/mixins/workflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,7 @@ export const workflowHelpers = mixins(
return workflowIssues;
},

// Returns a workflow instance.
getWorkflow (nodes?: INodeUi[], connections?: IConnections, copyData?: boolean): Workflow {
nodes = nodes || this.getNodes();
connections = connections || (this.$store.getters.allConnections as IConnections);

getNodeTypes (): INodeTypes {
const nodeTypes: INodeTypes = {
nodeTypes: {},
init: async (nodeTypes?: INodeTypeData): Promise<void> => { },
Expand All @@ -287,6 +283,15 @@ export const workflowHelpers = mixins(
},
};

return nodeTypes;
},

// Returns a workflow instance.
getWorkflow (nodes?: INodeUi[], connections?: IConnections, copyData?: boolean): Workflow {
nodes = nodes || this.getNodes();
connections = connections || (this.$store.getters.allConnections as IConnections);

const nodeTypes = this.getNodeTypes();
let workflowId = this.$store.getters.workflowId;
if (workflowId === PLACEHOLDER_EMPTY_WORKFLOW_ID) {
workflowId = undefined;
Expand Down
10 changes: 9 additions & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ import {
IRun,
ITaskData,
INodeCredentialsDetails,
TelemetryHelpers,
IWorkflowBase,
} from 'n8n-workflow';
import {
ICredentialsResponse,
Expand Down Expand Up @@ -409,7 +411,13 @@ export default mixins(
this.runWorkflow(nodeName, source);
},
onRunWorkflow() {
this.$telemetry.track('User clicked execute workflow button', { workflow_id: this.$store.getters.workflowId });
this.getWorkflowDataToSave().then((workflowData) => {
this.$telemetry.track('User clicked execute workflow button', {
workflow_id: this.$store.getters.workflowId,
node_graph_string: JSON.stringify(TelemetryHelpers.generateNodesGraph(workflowData as IWorkflowBase, this.getNodeTypes()).nodeGraph),
});
});
this.runWorkflow();
},
onCreateMenuHoverIn(mouseinEvent: MouseEvent) {
Expand Down
9 changes: 2 additions & 7 deletions packages/workflow/src/TelemetryHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
} from '.';
import { INodeType } from './Interfaces';

import { getInstance as getLoggerInstance } from './LoggerProxy';

const STICKY_NODE_TYPE = 'n8n-nodes-base.stickyNote';

export function getNodeTypeForName(workflow: IWorkflowBase, nodeName: string): INode | undefined {
Expand Down Expand Up @@ -213,11 +211,8 @@ export function generateNodesGraph(
});
});
});
} catch (e) {
const logger = getLoggerInstance();
logger.warn(`Failed to generate nodes graph for workflowId: ${workflow.id as string | number}`);
logger.warn((e as Error).message);
logger.warn((e as Error).stack ?? '');
} catch (_) {
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex, webhookNodeName };
}

return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex, webhookNodeName };
Expand Down

0 comments on commit 3797c73

Please sign in to comment.