mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
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:
committed by
GitHub
parent
d80b49d6e5
commit
cb5a803f9e
29
packages/cli/src/modules/insights/insights.module.ts
Normal file
29
packages/cli/src/modules/insights/insights.module.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user