mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(core): Load insights module on webhook instance to save insights on webhook workflows (#15433)
This commit is contained in:
committed by
GitHub
parent
d9fdef3bf9
commit
bf5551d711
@@ -1,22 +1,25 @@
|
|||||||
import { mock } from 'jest-mock-extended';
|
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 type { ModulePreInitContext } from '@/modules/modules.config';
|
||||||
|
|
||||||
import { shouldLoadModule } from '../insights.pre-init';
|
import { shouldLoadModule } from '../insights.pre-init';
|
||||||
|
|
||||||
describe('InsightsModulePreInit', () => {
|
describe('InsightsModulePreInit', () => {
|
||||||
it('should return false if instance type is not "main"', () => {
|
it('should return false if instance type is worker', () => {
|
||||||
const ctx: ModulePreInitContext = {
|
const ctx: ModulePreInitContext = {
|
||||||
instance: mock<InstanceSettings>({ instanceType: 'worker' }),
|
instance: mock<InstanceSettings>({ instanceType: 'worker' }),
|
||||||
};
|
};
|
||||||
expect(shouldLoadModule(ctx)).toBe(false);
|
expect(shouldLoadModule(ctx)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if instance type is "main"', () => {
|
it.each<InstanceType>(['main', 'webhook'])(
|
||||||
const ctx: ModulePreInitContext = {
|
'should return true if instance type is "%s"',
|
||||||
instance: mock<InstanceSettings>({ instanceType: 'main' }),
|
(instanceType) => {
|
||||||
};
|
const ctx: ModulePreInitContext = {
|
||||||
expect(shouldLoadModule(ctx)).toBe(true);
|
instance: mock<InstanceSettings>({ instanceType }),
|
||||||
});
|
};
|
||||||
|
expect(shouldLoadModule(ctx)).toBe(true);
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { ModulePreInitContext } from '../modules.config';
|
import type { ModulePreInitContext } from '../modules.config';
|
||||||
|
|
||||||
export const shouldLoadModule = (ctx: ModulePreInitContext) =>
|
export const shouldLoadModule = (ctx: ModulePreInitContext) =>
|
||||||
// Only main instance(s) should collect insights
|
// Only main and webhook instance(s) should collect insights
|
||||||
// Because main instances are informed of all finished workflow executions, whatever the mode
|
// Because main and webhooks instances are the ones informed of all finished workflow executions, whatever the mode
|
||||||
ctx.instance.instanceType === 'main';
|
ctx.instance.instanceType === 'main' || ctx.instance.instanceType === 'webhook';
|
||||||
|
|||||||
Reference in New Issue
Block a user