diff --git a/packages/cli/src/modules/insights/__tests__/insights.pre-init.test.ts b/packages/cli/src/modules/insights/__tests__/insights.pre-init.test.ts index 0ffb5ea13a..1af0a9df84 100644 --- a/packages/cli/src/modules/insights/__tests__/insights.pre-init.test.ts +++ b/packages/cli/src/modules/insights/__tests__/insights.pre-init.test.ts @@ -1,22 +1,25 @@ import { mock } from 'jest-mock-extended'; -import type { InstanceSettings } from 'n8n-core'; +import type { InstanceSettings, InstanceType } from 'n8n-core'; import type { ModulePreInitContext } from '@/modules/modules.config'; import { shouldLoadModule } from '../insights.pre-init'; describe('InsightsModulePreInit', () => { - it('should return false if instance type is not "main"', () => { + it('should return false if instance type is worker', () => { const ctx: ModulePreInitContext = { instance: mock({ instanceType: 'worker' }), }; expect(shouldLoadModule(ctx)).toBe(false); }); - it('should return true if instance type is "main"', () => { - const ctx: ModulePreInitContext = { - instance: mock({ instanceType: 'main' }), - }; - expect(shouldLoadModule(ctx)).toBe(true); - }); + it.each(['main', 'webhook'])( + 'should return true if instance type is "%s"', + (instanceType) => { + const ctx: ModulePreInitContext = { + instance: mock({ instanceType }), + }; + expect(shouldLoadModule(ctx)).toBe(true); + }, + ); }); diff --git a/packages/cli/src/modules/insights/insights.pre-init.ts b/packages/cli/src/modules/insights/insights.pre-init.ts index b91be86e34..a8a6267e7a 100644 --- a/packages/cli/src/modules/insights/insights.pre-init.ts +++ b/packages/cli/src/modules/insights/insights.pre-init.ts @@ -1,6 +1,6 @@ import type { ModulePreInitContext } from '../modules.config'; export const shouldLoadModule = (ctx: ModulePreInitContext) => - // Only main instance(s) should collect insights - // Because main instances are informed of all finished workflow executions, whatever the mode - ctx.instance.instanceType === 'main'; + // Only main and webhook instance(s) should collect insights + // Because main and webhooks instances are the ones informed of all finished workflow executions, whatever the mode + ctx.instance.instanceType === 'main' || ctx.instance.instanceType === 'webhook';