mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 01:37:07 +02:00
chore(core): Add instanceType condition to load insights module only for main aand webhook (#22052)
This commit is contained in:
parent
34039b370b
commit
db16933c5e
|
|
@ -7,6 +7,7 @@ import { mock } from 'jest-mock-extended';
|
|||
import { InstanceSettings } from 'n8n-core';
|
||||
|
||||
import { InsightsModule } from '../insights.module';
|
||||
import { InsightsService } from '../insights.service';
|
||||
|
||||
describe('InsightsModule', () => {
|
||||
let insightsModule: InsightsModule;
|
||||
|
|
@ -23,11 +24,23 @@ describe('InsightsModule', () => {
|
|||
beforeEach(async () => {
|
||||
jest.clearAllMocks();
|
||||
await testDb.truncate(['Project']);
|
||||
insightsModule = Container.get(InsightsModule);
|
||||
|
||||
mockInstanceSettings = mock<InstanceSettings>();
|
||||
Container.set(InstanceSettings, mockInstanceSettings);
|
||||
Container.set(Logger, mockLogger());
|
||||
Container.set(LicenseState, mock<LicenseState>());
|
||||
Container.set(
|
||||
InsightsService,
|
||||
new InsightsService(
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
Container.get(LicenseState),
|
||||
mockInstanceSettings,
|
||||
Container.get(Logger),
|
||||
),
|
||||
);
|
||||
insightsModule = Container.get(InsightsModule);
|
||||
await createTeamProject();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
import type { ModuleInterface } from '@n8n/decorators';
|
||||
import { BackendModule, OnShutdown } from '@n8n/decorators';
|
||||
import { Container } from '@n8n/di';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
|
||||
@BackendModule({ name: 'insights' })
|
||||
/**
|
||||
* Only main- and webhook-type instances collect insights because
|
||||
* only they are informed of finished workflow executions.
|
||||
*/
|
||||
@BackendModule({ name: 'insights', instanceTypes: ['main', 'webhook'] })
|
||||
export class InsightsModule implements ModuleInterface {
|
||||
async init() {
|
||||
/**
|
||||
* Only main- and webhook-type instances collect insights because
|
||||
* only they are informed of finished workflow executions.
|
||||
*/
|
||||
if (Container.get(InstanceSettings).instanceType === 'worker') return;
|
||||
|
||||
await import('./insights.controller');
|
||||
|
||||
const { InsightsService } = await import('./insights.service');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user