Files
n8n-enterprise-unlocked/packages/cli/src/modules/insights/insights.module.ts
Guillaume Jacquart cb5a803f9e 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>
2025-03-20 20:25:29 +01:00

30 lines
932 B
TypeScript

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);
});
}
}
}