refactor: Telemetry updates (#3529)

* Init unit tests for telemetry

* Update telemetry tests

* Test Workflow execution errored event

* Add new tracking logic in pulse

* cleanup

* interfaces

* Add event_version for Workflow execution count event

* add version_cli in all events

* add user saved credentials event

* update manual wf exec finished, fixes

* improve typings, lint

* add node_graph_string in User clicked execute workflow button event

* add User set node operation or mode event

* Add instance started event in FE

* Add User clicked retry execution button event

* add expression editor event

* add input node type to add node event

* add User stopped workflow execution wvent

* add error message in saved credential event

* update stop execution event

* add execution preflight event

* Remove instance started even tfrom FE, add session started to FE,BE

* improve typing

* remove node_graph as property from all events

* move back from default export

* move psl npm package to cli package

* cr

* update webhook node domain logic

* fix is_valid for User saved credentials event

* fix Expression Editor variable selector event

* add caused_by_credential in preflight event

* undo webhook_domain

* change node_type to full type

* add webhook_domain property in manual execution event (#3680)

* add webhook_domain property in manual execution event

* lint fix
This commit is contained in:
Ahsan Virani
2022-07-10 08:53:04 +02:00
committed by GitHub
parent 32c68eb126
commit 6b2db8e4f4
18 changed files with 719 additions and 139 deletions

View File

@@ -52,13 +52,13 @@
"typescript": "~4.6.0"
},
"dependencies": {
"@n8n_io/riot-tmpl": "^1.0.1",
"jmespath": "^0.16.0",
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"lodash.merge": "^4.6.2",
"lodash.set": "^4.3.2",
"luxon": "^2.3.0",
"@n8n_io/riot-tmpl": "^1.0.1",
"xml2js": "^0.4.23"
},
"jest": {

View File

@@ -1476,6 +1476,11 @@ export type PropertiesOf<M extends { resource: string; operation: string }> = Ar
// Telemetry
export interface ITelemetryTrackProperties {
user_id?: string;
[key: string]: GenericValue;
}
export interface INodesGraph {
node_types: string[];
node_connections: IDataObject[];
@@ -1519,6 +1524,7 @@ export interface INodeNameIndex {
export interface INodesGraphResult {
nodeGraph: INodesGraph;
nameIndices: INodeNameIndex;
webhookNodeNames: string[];
}
export interface ITelemetryClientConfig {

View File

@@ -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 {
@@ -124,6 +122,7 @@ export function generateNodesGraph(
notes: {},
};
const nodeNameAndIndex: INodeNameIndex = {};
const webhookNodeNames: string[] = [];
try {
const notes = workflow.nodes.filter((node) => node.type === STICKY_NODE_TYPE);
@@ -177,6 +176,8 @@ export function generateNodesGraph(
nodeItem.domain_base = getDomainBase(url);
nodeItem.domain_path = getDomainPath(url);
nodeItem.method = node.parameters.requestMethod as string;
} else if (node.type === 'n8n-nodes-base.webhook') {
webhookNodeNames.push(node.name);
} else {
const nodeType = nodeTypes.getByNameAndVersion(node.type);
@@ -210,12 +211,9 @@ 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, webhookNodeNames };
}
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex };
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex, webhookNodeNames };
}