mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +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": {
|
"dependencies": {
|
||||||
"@n8n/client-oauth2": "workspace:*",
|
"@n8n/client-oauth2": "workspace:*",
|
||||||
"@n8n_io/license-sdk": "~2.6.1",
|
"@n8n_io/license-sdk": "~2.7.1",
|
||||||
"@oclif/command": "^1.8.16",
|
"@oclif/command": "^1.8.16",
|
||||||
"@oclif/config": "^1.18.17",
|
"@oclif/config": "^1.18.17",
|
||||||
"@oclif/core": "^1.16.4",
|
"@oclif/core": "^1.16.4",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
UNLIMITED_LICENSE_QUOTA,
|
UNLIMITED_LICENSE_QUOTA,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import Container, { Service } from 'typedi';
|
import Container, { Service } from 'typedi';
|
||||||
|
import { WorkflowRepository } from '@/databases/repositories';
|
||||||
import type { BooleanLicenseFeature, N8nInstanceType, NumericLicenseFeature } from './Interfaces';
|
import type { BooleanLicenseFeature, N8nInstanceType, NumericLicenseFeature } from './Interfaces';
|
||||||
import type { RedisServicePubSubPublisher } from './services/redis/RedisServicePubSubPublisher';
|
import type { RedisServicePubSubPublisher } from './services/redis/RedisServicePubSubPublisher';
|
||||||
import { RedisService } from './services/redis.service';
|
import { RedisService } from './services/redis.service';
|
||||||
@@ -51,6 +52,9 @@ export class License {
|
|||||||
const onFeatureChange = isMainInstance
|
const onFeatureChange = isMainInstance
|
||||||
? async (features: TFeatures) => this.onFeatureChange(features)
|
? async (features: TFeatures) => this.onFeatureChange(features)
|
||||||
: async () => {};
|
: async () => {};
|
||||||
|
const collectUsageMetrics = isMainInstance
|
||||||
|
? async () => this.collectUsageMetrics()
|
||||||
|
: async () => [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.manager = new LicenseManager({
|
this.manager = new LicenseManager({
|
||||||
@@ -65,6 +69,7 @@ export class License {
|
|||||||
loadCertStr: async () => this.loadCertStr(),
|
loadCertStr: async () => this.loadCertStr(),
|
||||||
saveCertStr,
|
saveCertStr,
|
||||||
deviceFingerprint: () => this.instanceSettings.instanceId,
|
deviceFingerprint: () => this.instanceSettings.instanceId,
|
||||||
|
collectUsageMetrics,
|
||||||
onFeatureChange,
|
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> {
|
async loadCertStr(): Promise<TLicenseBlock> {
|
||||||
// if we have an ephemeral license, we don't want to load it from the database
|
// if we have an ephemeral license, we don't want to load it from the database
|
||||||
const ephemeralLicense = config.get('license.cert');
|
const ephemeralLicense = config.get('license.cert');
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ describe('License', () => {
|
|||||||
loadCertStr: expect.any(Function),
|
loadCertStr: expect.any(Function),
|
||||||
saveCertStr: expect.any(Function),
|
saveCertStr: expect.any(Function),
|
||||||
onFeatureChange: expect.any(Function),
|
onFeatureChange: expect.any(Function),
|
||||||
|
collectUsageMetrics: expect.any(Function),
|
||||||
server: MOCK_SERVER_URL,
|
server: MOCK_SERVER_URL,
|
||||||
tenantId: 1,
|
tenantId: 1,
|
||||||
});
|
});
|
||||||
@@ -61,6 +62,7 @@ describe('License', () => {
|
|||||||
loadCertStr: expect.any(Function),
|
loadCertStr: expect.any(Function),
|
||||||
saveCertStr: expect.any(Function),
|
saveCertStr: expect.any(Function),
|
||||||
onFeatureChange: expect.any(Function),
|
onFeatureChange: expect.any(Function),
|
||||||
|
collectUsageMetrics: expect.any(Function),
|
||||||
server: MOCK_SERVER_URL,
|
server: MOCK_SERVER_URL,
|
||||||
tenantId: 1,
|
tenantId: 1,
|
||||||
});
|
});
|
||||||
|
|||||||
25
pnpm-lock.yaml
generated
25
pnpm-lock.yaml
generated
@@ -195,8 +195,8 @@ importers:
|
|||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../@n8n/client-oauth2
|
version: link:../@n8n/client-oauth2
|
||||||
'@n8n_io/license-sdk':
|
'@n8n_io/license-sdk':
|
||||||
specifier: ~2.6.1
|
specifier: ~2.7.1
|
||||||
version: 2.6.1
|
version: 2.7.1
|
||||||
'@oclif/command':
|
'@oclif/command':
|
||||||
specifier: ^1.8.16
|
specifier: ^1.8.16
|
||||||
version: 1.8.18(@oclif/config@1.18.17)(supports-color@8.1.1)
|
version: 1.8.18(@oclif/config@1.18.17)(supports-color@8.1.1)
|
||||||
@@ -3956,6 +3956,11 @@ packages:
|
|||||||
resolution: {integrity: sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ==}
|
resolution: {integrity: sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@fastify/busboy@2.0.0:
|
||||||
|
resolution: {integrity: sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@floating-ui/core@1.3.1:
|
/@floating-ui/core@1.3.1:
|
||||||
resolution: {integrity: sha512-Bu+AMaXNjrpjh41znzHqaz3r2Nr8hHuHZT6V2LBKMhyMl0FgKA62PNYbqnfgmzOhoWZj70Zecisbo4H1rotP5g==}
|
resolution: {integrity: sha512-Bu+AMaXNjrpjh41znzHqaz3r2Nr8hHuHZT6V2LBKMhyMl0FgKA62PNYbqnfgmzOhoWZj70Zecisbo4H1rotP5g==}
|
||||||
dev: false
|
dev: false
|
||||||
@@ -4681,14 +4686,14 @@ packages:
|
|||||||
acorn-walk: 8.2.0
|
acorn-walk: 8.2.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@n8n_io/license-sdk@2.6.1:
|
/@n8n_io/license-sdk@2.7.1:
|
||||||
resolution: {integrity: sha512-N4yBzgNIRrQlhy+BWyEC9cbf86asPxryWbJpmrfeaqkFpBR6Z5yIqmWRGnLs7XKVC9se8cdWlF7EWKtaH6oDPA==}
|
resolution: {integrity: sha512-SiPKI/wN2coLPB8Tyb28UlLgAszU2SkSR8PWNioTWAd8PnUhTYg8KN9jfUOZipVF+YMOAHc/hQUq6kJA1PF0xg==}
|
||||||
engines: {node: '>=14.0.0', npm: '>=7.10.0'}
|
engines: {node: '>=18.12.1', npm: '>=8.19.2'}
|
||||||
dependencies:
|
dependencies:
|
||||||
crypto-js: 4.1.1
|
crypto-js: 4.1.1
|
||||||
node-machine-id: 1.1.12
|
node-machine-id: 1.1.12
|
||||||
node-rsa: 1.1.1
|
node-rsa: 1.1.1
|
||||||
undici: 5.21.0
|
undici: 5.26.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@n8n_io/riot-tmpl@4.0.0:
|
/@n8n_io/riot-tmpl@4.0.0:
|
||||||
@@ -21213,11 +21218,11 @@ packages:
|
|||||||
undertaker-registry: 1.0.1
|
undertaker-registry: 1.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/undici@5.21.0:
|
/undici@5.26.4:
|
||||||
resolution: {integrity: sha512-HOjK8l6a57b2ZGXOcUsI5NLfoTrfmbOl90ixJDl0AEFG4wgHNDQxtZy15/ZQp7HhjkpaGlp/eneMgtsu1dIlUA==}
|
resolution: {integrity: sha512-OG+QOf0fTLtazL9P9X7yqWxQ+Z0395Wk6DSkyTxtaq3wQEjIroVe7Y4asCX/vcCxYpNGMnwz8F0qbRYUoaQVMw==}
|
||||||
engines: {node: '>=12.18'}
|
engines: {node: '>=14.0'}
|
||||||
dependencies:
|
dependencies:
|
||||||
busboy: 1.6.0
|
'@fastify/busboy': 2.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/unescape@1.0.1:
|
/unescape@1.0.1:
|
||||||
|
|||||||
Reference in New Issue
Block a user