mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
feat(core): Add metadata (customdata) to event log (#6334)
* add metadata (customdata) to event log * lint fix * use reduce
This commit is contained in:
parent
f91d36cd30
commit
792b1c1ffb
|
@ -31,6 +31,7 @@ import type { User } from '@db/entities/User';
|
||||||
import { N8N_VERSION } from '@/constants';
|
import { N8N_VERSION } from '@/constants';
|
||||||
import * as Db from '@/Db';
|
import * as Db from '@/Db';
|
||||||
import { NodeTypes } from './NodeTypes';
|
import { NodeTypes } from './NodeTypes';
|
||||||
|
import type { ExecutionMetadata } from './databases/entities/ExecutionMetadata';
|
||||||
|
|
||||||
function userToPayload(user: User): {
|
function userToPayload(user: User): {
|
||||||
userId: string;
|
userId: string;
|
||||||
|
@ -253,7 +254,17 @@ export class InternalHooks implements IInternalHooksClass {
|
||||||
executionId: string,
|
executionId: string,
|
||||||
executionMode: WorkflowExecuteMode,
|
executionMode: WorkflowExecuteMode,
|
||||||
workflowData?: IWorkflowBase,
|
workflowData?: IWorkflowBase,
|
||||||
|
executionMetadata?: ExecutionMetadata[],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
let metaData;
|
||||||
|
try {
|
||||||
|
if (executionMetadata) {
|
||||||
|
metaData = executionMetadata.reduce((acc, meta) => {
|
||||||
|
return { ...acc, [meta.key]: meta.value };
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
void Promise.all([
|
void Promise.all([
|
||||||
eventBus.sendWorkflowEvent({
|
eventBus.sendWorkflowEvent({
|
||||||
eventName: 'n8n.workflow.crashed',
|
eventName: 'n8n.workflow.crashed',
|
||||||
|
@ -262,6 +273,7 @@ export class InternalHooks implements IInternalHooksClass {
|
||||||
isManual: executionMode === 'manual',
|
isManual: executionMode === 'manual',
|
||||||
workflowId: workflowData?.id?.toString(),
|
workflowId: workflowData?.id?.toString(),
|
||||||
workflowName: workflowData?.name,
|
workflowName: workflowData?.name,
|
||||||
|
metaData,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
@ -430,6 +442,7 @@ export class InternalHooks implements IInternalHooksClass {
|
||||||
workflowId: properties.workflow_id,
|
workflowId: properties.workflow_id,
|
||||||
isManual: properties.is_manual,
|
isManual: properties.is_manual,
|
||||||
workflowName: workflow.name,
|
workflowName: workflow.name,
|
||||||
|
metaData: runData?.data?.resultData?.metadata,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: eventBus.sendWorkflowEvent({
|
: eventBus.sendWorkflowEvent({
|
||||||
|
@ -445,6 +458,7 @@ export class InternalHooks implements IInternalHooksClass {
|
||||||
errorMessage: properties.error_message?.toString(),
|
errorMessage: properties.error_message?.toString(),
|
||||||
isManual: properties.is_manual,
|
isManual: properties.is_manual,
|
||||||
workflowName: workflow.name,
|
workflowName: workflow.name,
|
||||||
|
metaData: runData?.data?.resultData?.metadata,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -133,6 +133,7 @@ export class WorkflowRunner {
|
||||||
executionId,
|
executionId,
|
||||||
executionMode,
|
executionMode,
|
||||||
executionFlattedData?.workflowData,
|
executionFlattedData?.workflowData,
|
||||||
|
executionFlattedData?.metadata,
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors
|
// Ignore errors
|
||||||
|
|
|
@ -359,7 +359,11 @@ export class MessageEventBusDestinationWebhook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
LoggerProxy.warn(
|
||||||
|
`Webhook destination ${this.label} failed to send message to: ${this.url} - ${
|
||||||
|
(error as Error).message
|
||||||
|
}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendResult;
|
return sendResult;
|
||||||
|
|
Loading…
Reference in a new issue