mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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 * as Db from '@/Db';
|
||||
import { NodeTypes } from './NodeTypes';
|
||||
import type { ExecutionMetadata } from './databases/entities/ExecutionMetadata';
|
||||
|
||||
function userToPayload(user: User): {
|
||||
userId: string;
|
||||
|
@ -253,7 +254,17 @@ export class InternalHooks implements IInternalHooksClass {
|
|||
executionId: string,
|
||||
executionMode: WorkflowExecuteMode,
|
||||
workflowData?: IWorkflowBase,
|
||||
executionMetadata?: ExecutionMetadata[],
|
||||
): Promise<void> {
|
||||
let metaData;
|
||||
try {
|
||||
if (executionMetadata) {
|
||||
metaData = executionMetadata.reduce((acc, meta) => {
|
||||
return { ...acc, [meta.key]: meta.value };
|
||||
}, {});
|
||||
}
|
||||
} catch {}
|
||||
|
||||
void Promise.all([
|
||||
eventBus.sendWorkflowEvent({
|
||||
eventName: 'n8n.workflow.crashed',
|
||||
|
@ -262,6 +273,7 @@ export class InternalHooks implements IInternalHooksClass {
|
|||
isManual: executionMode === 'manual',
|
||||
workflowId: workflowData?.id?.toString(),
|
||||
workflowName: workflowData?.name,
|
||||
metaData,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
@ -430,6 +442,7 @@ export class InternalHooks implements IInternalHooksClass {
|
|||
workflowId: properties.workflow_id,
|
||||
isManual: properties.is_manual,
|
||||
workflowName: workflow.name,
|
||||
metaData: runData?.data?.resultData?.metadata,
|
||||
},
|
||||
})
|
||||
: eventBus.sendWorkflowEvent({
|
||||
|
@ -445,6 +458,7 @@ export class InternalHooks implements IInternalHooksClass {
|
|||
errorMessage: properties.error_message?.toString(),
|
||||
isManual: properties.is_manual,
|
||||
workflowName: workflow.name,
|
||||
metaData: runData?.data?.resultData?.metadata,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -133,6 +133,7 @@ export class WorkflowRunner {
|
|||
executionId,
|
||||
executionMode,
|
||||
executionFlattedData?.workflowData,
|
||||
executionFlattedData?.metadata,
|
||||
);
|
||||
} catch {
|
||||
// Ignore errors
|
||||
|
|
|
@ -359,7 +359,11 @@ export class MessageEventBusDestinationWebhook
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
LoggerProxy.warn(
|
||||
`Webhook destination ${this.label} failed to send message to: ${this.url} - ${
|
||||
(error as Error).message
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
return sendResult;
|
||||
|
|
Loading…
Reference in a new issue