mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
30 lines
932 B
TypeScript
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);
|
|
});
|
|
}
|
|
}
|
|
}
|