feat(core): Store insights data at the end of executions (no-changelog) (#13905)

Co-authored-by: Danny Martini <danny@n8n.io>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Guillaume Jacquart
2025-03-20 20:25:29 +01:00
committed by GitHub
parent d80b49d6e5
commit cb5a803f9e
23 changed files with 941 additions and 5 deletions

View File

@@ -0,0 +1,29 @@
import type { ExecutionLifecycleHooks } from 'n8n-core';
import { InstanceSettings, Logger } from 'n8n-core';
import type { BaseN8nModule } from '@/decorators/module';
import { N8nModule } from '@/decorators/module';
import { InsightsService } from './insights.service';
@N8nModule()
export class InsightsModule implements BaseN8nModule {
constructor(
private readonly logger: Logger,
private readonly insightsService: InsightsService,
private readonly instanceSettings: InstanceSettings,
) {
this.logger = this.logger.scoped('insights');
}
registerLifecycleHooks(hooks: ExecutionLifecycleHooks) {
const insightsService = this.insightsService;
// Workers should not be saving any insights
if (this.instanceSettings.instanceType !== 'worker') {
hooks.addHandler('workflowExecuteAfter', async function (fullRunData) {
await insightsService.workflowExecuteAfterHandler(this, fullRunData);
});
}
}
}