mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat: Collect usage metrics on license renewal (no-changelog) (#7486)
This commit is contained in:
committed by
GitHub
parent
774fe202bf
commit
3ef771ea38
@@ -99,7 +99,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@n8n/client-oauth2": "workspace:*",
|
||||
"@n8n_io/license-sdk": "~2.6.1",
|
||||
"@n8n_io/license-sdk": "~2.7.1",
|
||||
"@oclif/command": "^1.8.16",
|
||||
"@oclif/config": "^1.18.17",
|
||||
"@oclif/core": "^1.16.4",
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
UNLIMITED_LICENSE_QUOTA,
|
||||
} from './constants';
|
||||
import Container, { Service } from 'typedi';
|
||||
import { WorkflowRepository } from '@/databases/repositories';
|
||||
import type { BooleanLicenseFeature, N8nInstanceType, NumericLicenseFeature } from './Interfaces';
|
||||
import type { RedisServicePubSubPublisher } from './services/redis/RedisServicePubSubPublisher';
|
||||
import { RedisService } from './services/redis.service';
|
||||
@@ -51,6 +52,9 @@ export class License {
|
||||
const onFeatureChange = isMainInstance
|
||||
? async (features: TFeatures) => this.onFeatureChange(features)
|
||||
: async () => {};
|
||||
const collectUsageMetrics = isMainInstance
|
||||
? async () => this.collectUsageMetrics()
|
||||
: async () => [];
|
||||
|
||||
try {
|
||||
this.manager = new LicenseManager({
|
||||
@@ -65,6 +69,7 @@ export class License {
|
||||
loadCertStr: async () => this.loadCertStr(),
|
||||
saveCertStr,
|
||||
deviceFingerprint: () => this.instanceSettings.instanceId,
|
||||
collectUsageMetrics,
|
||||
onFeatureChange,
|
||||
});
|
||||
|
||||
@@ -76,6 +81,15 @@ export class License {
|
||||
}
|
||||
}
|
||||
|
||||
async collectUsageMetrics() {
|
||||
return [
|
||||
{
|
||||
name: 'activeWorkflows',
|
||||
value: await Container.get(WorkflowRepository).count({ where: { active: true } }),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async loadCertStr(): Promise<TLicenseBlock> {
|
||||
// if we have an ephemeral license, we don't want to load it from the database
|
||||
const ephemeralLicense = config.get('license.cert');
|
||||
|
||||
@@ -42,6 +42,7 @@ describe('License', () => {
|
||||
loadCertStr: expect.any(Function),
|
||||
saveCertStr: expect.any(Function),
|
||||
onFeatureChange: expect.any(Function),
|
||||
collectUsageMetrics: expect.any(Function),
|
||||
server: MOCK_SERVER_URL,
|
||||
tenantId: 1,
|
||||
});
|
||||
@@ -61,6 +62,7 @@ describe('License', () => {
|
||||
loadCertStr: expect.any(Function),
|
||||
saveCertStr: expect.any(Function),
|
||||
onFeatureChange: expect.any(Function),
|
||||
collectUsageMetrics: expect.any(Function),
|
||||
server: MOCK_SERVER_URL,
|
||||
tenantId: 1,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user