Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch node improvements - N8N-3131 #2420

Merged
merged 23 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
00f4420
πŸ› ES query string not passed to request
pemontto Nov 9, 2021
5a3161f
πŸ”‘ Add ES credential test
pemontto Nov 9, 2021
04a74eb
✨ Add ES index pipelines and index refresh
pemontto Nov 9, 2021
6fec179
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Mar 15, 2022
9a9ba08
:hammer: merge fix
michael-radency Mar 16, 2022
3f790d2
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Mar 16, 2022
7dac4bb
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Mar 29, 2022
e3ba072
:zap: renamed additional filds as options
michael-radency Mar 29, 2022
b7c21b0
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Apr 21, 2022
9f3860d
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Apr 26, 2022
3991253
Merge branch 'master' of https://github.com/n8n-io/n8n into elasticse…
michael-radency Apr 26, 2022
6fd4509
:zap: added ignore ssl to credentials
michael-radency Apr 26, 2022
adcd00f
:zap: Improvements
RicardoE105 Jul 8, 2022
a7e9c84
πŸ”€ Merge master
RicardoE105 Jul 8, 2022
291d118
:zap: Improvements
RicardoE105 Jul 8, 2022
32c68eb
feat(Redis Node): Add push and pop operations (#3127)
pemontto Jul 10, 2022
6b2db8e
refactor: Telemetry updates (#3529)
ahsanv Jul 10, 2022
dbfb8d5
feat(SpreadsheetFile Node): Allow skipping headers when writing sprea…
drudge Jul 10, 2022
af45a07
fix(Telegram Node): Fix sending binaryData media (photo, document, vi…
tahasonmez Jul 10, 2022
dbc0280
feat(Freshworks CRM Node): Add Search + Lookup functionality (#3131)
JanThiel Jul 10, 2022
25093b6
feat(Jira Trigger Node): Add optional query auth for security (#3172)
pemontto Jul 10, 2022
556a6f1
:twisted_rightwards_arrows: Merge branch 'elasticsearch-improvements'…
janober Jul 10, 2022
14faab6
:zap: Changed authentication to use the generic type
janober Jul 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@types/open": "^6.1.0",
"@types/parseurl": "^1.3.1",
"@types/passport-jwt": "^3.0.6",
"@types/psl": "^1.1.0",
"@types/request-promise-native": "~1.0.15",
"@types/superagent": "4.1.13",
"@types/supertest": "^2.0.11",
Expand Down Expand Up @@ -145,6 +146,7 @@
"passport-jwt": "^4.0.0",
"pg": "^8.3.0",
"prom-client": "^13.1.0",
"psl": "^1.8.0",
"request-promise-native": "^1.0.7",
"shelljs": "^0.8.5",
"sqlite3": "^5.0.2",
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
IRunExecutionData,
ITaskData,
ITelemetrySettings,
ITelemetryTrackProperties,
IWorkflowBase as IWorkflowBaseWorkflow,
Workflow,
WorkflowExecuteMode,
Expand Down Expand Up @@ -667,3 +668,14 @@ export interface IWorkflowExecuteProcess {
}

export type WhereClause = Record<string, { id: string }>;

// ----------------------------------
// telemetry
// ----------------------------------

export interface IExecutionTrackProperties extends ITelemetryTrackProperties {
workflow_id: string;
success: boolean;
error_node_type?: string;
is_manual: boolean;
}
57 changes: 40 additions & 17 deletions packages/cli/src/InternalHooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/* eslint-disable import/no-cycle */
import { get as pslGet } from 'psl';
import { BinaryDataManager } from 'n8n-core';
import { IDataObject, INodeTypes, IRun, TelemetryHelpers } from 'n8n-workflow';
import {
INodesGraphResult,
INodeTypes,
IRun,
ITelemetryTrackProperties,
TelemetryHelpers,
} from 'n8n-workflow';
import { snakeCase } from 'change-case';
import {
IDiagnosticInfo,
Expand All @@ -10,6 +17,7 @@ import {
IWorkflowDb,
} from '.';
import { Telemetry } from './telemetry';
import { IExecutionTrackProperties } from './Interfaces';

export class InternalHooksClass implements IInternalHooksClass {
private versionCli: string;
Expand Down Expand Up @@ -48,6 +56,10 @@ export class InternalHooksClass implements IInternalHooksClass {
]);
}

async onFrontendSettingsAPI(sessionId?: string): Promise<void> {
return this.telemetry.track('Session started', { session_id: sessionId });
}

async onPersonalizationSurveySubmitted(
userId: string,
answers: Record<string, string>,
Expand All @@ -73,7 +85,6 @@ export class InternalHooksClass implements IInternalHooksClass {
return this.telemetry.track('User created workflow', {
user_id: userId,
workflow_id: workflow.id,
node_graph: nodeGraph,
node_graph_string: JSON.stringify(nodeGraph),
public_api: publicApi,
});
Expand All @@ -98,7 +109,6 @@ export class InternalHooksClass implements IInternalHooksClass {
return this.telemetry.track('User saved workflow', {
user_id: userId,
workflow_id: workflow.id,
node_graph: nodeGraph,
node_graph_string: JSON.stringify(nodeGraph),
notes_count_overlapping: overlappingCount,
notes_count_non_overlapping: notesCount - overlappingCount,
Expand All @@ -115,10 +125,16 @@ export class InternalHooksClass implements IInternalHooksClass {
userId?: string,
): Promise<void> {
const promises = [Promise.resolve()];
const properties: IDataObject = {
workflow_id: workflow.id,

if (!workflow.id) {
return Promise.resolve();
}

const properties: IExecutionTrackProperties = {
workflow_id: workflow.id.toString(),
is_manual: false,
version_cli: this.versionCli,
success: false,
};

if (userId) {
Expand All @@ -130,7 +146,7 @@ export class InternalHooksClass implements IInternalHooksClass {
properties.success = !!runData.finished;
properties.is_manual = runData.mode === 'manual';

let nodeGraphResult;
let nodeGraphResult: INodesGraphResult | null = null;

if (!properties.success && runData?.data.resultData.error) {
properties.error_message = runData?.data.resultData.error.message;
Expand Down Expand Up @@ -165,22 +181,19 @@ export class InternalHooksClass implements IInternalHooksClass {
nodeGraphResult = TelemetryHelpers.generateNodesGraph(workflow, this.nodeTypes);
}

const manualExecEventProperties = {
workflow_id: workflow.id,
const manualExecEventProperties: ITelemetryTrackProperties = {
workflow_id: workflow.id.toString(),
status: properties.success ? 'success' : 'failed',
error_message: properties.error_message,
error_message: properties.error_message as string,
error_node_type: properties.error_node_type,
node_graph: properties.node_graph,
node_graph_string: properties.node_graph_string,
error_node_id: properties.error_node_id,
node_graph_string: properties.node_graph_string as string,
error_node_id: properties.error_node_id as string,
webhook_domain: null,
};

if (!manualExecEventProperties.node_graph) {
if (!manualExecEventProperties.node_graph_string) {
nodeGraphResult = TelemetryHelpers.generateNodesGraph(workflow, this.nodeTypes);
manualExecEventProperties.node_graph = nodeGraphResult.nodeGraph;
manualExecEventProperties.node_graph_string = JSON.stringify(
manualExecEventProperties.node_graph,
);
manualExecEventProperties.node_graph_string = JSON.stringify(nodeGraphResult.nodeGraph);
}

if (runData.data.startData?.destinationNode) {
Expand All @@ -195,6 +208,16 @@ export class InternalHooksClass implements IInternalHooksClass {
}),
);
} else {
nodeGraphResult.webhookNodeNames.forEach((name: string) => {
const execJson = runData.data.resultData.runData[name]?.[0]?.data?.main?.[0]?.[0]
?.json as { headers?: { origin?: string } };
if (execJson?.headers?.origin && execJson.headers.origin !== '') {
manualExecEventProperties.webhook_domain = pslGet(
execJson.headers.origin.replace(/^https?:\/\//, ''),
);
}
});

promises.push(
this.telemetry.track('Manual workflow exec finished', manualExecEventProperties),
);
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2856,6 +2856,10 @@ class App {
`/${this.restEndpoint}/settings`,
ResponseHelper.send(
async (req: express.Request, res: express.Response): Promise<IN8nUISettings> => {
void InternalHooksManager.getInstance().onFrontendSettingsAPI(
req.headers.sessionid as string,
);

return this.getSettingsForFrontend();
},
),
Expand Down
Loading