Skip to content

Commit

Permalink
feat: add variable creation telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
valya committed Apr 4, 2023
1 parent afd8905 commit fb56535
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export interface IInternalHooksClass {
}): Promise<void>;
onApiKeyCreated(apiKeyDeletedData: { user: User; public_api: boolean }): Promise<void>;
onApiKeyDeleted(apiKeyDeletedData: { user: User; public_api: boolean }): Promise<void>;
onVariableCreated(createData: { variable_type: string }): Promise<void>;
}

export interface IVersionNotificationSettings {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/InternalHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,4 +978,8 @@ export class InternalHooks implements IInternalHooksClass {
async onAuditGeneratedViaCli() {
return this.telemetry.track('Instance generated security audit via CLI command');
}

async onVariableCreated(createData: { variable_type: string }): Promise<void> {
return this.telemetry.track('User created variable', createData);
}
}
3 changes: 3 additions & 0 deletions packages/cli/src/environments/variables.service.ee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Variables } from '@/databases/entities/Variables';
import { collections } from '@/Db';
import { InternalHooks } from '@/InternalHooks';
import Container from 'typedi';
import { canCreateNewVariable } from './enviromentHelpers';
import { VariablesService } from './variables.service';

Expand All @@ -14,6 +16,7 @@ export class EEVariablesService extends VariablesService {
if (!canCreateNewVariable(await this.getCount())) {
throw new VariablesLicenseError('Variables limit reached');
}
void Container.get(InternalHooks).onVariableCreated({ type: variable.type });
return collections.Variables.save(variable);
}

Expand Down

0 comments on commit fb56535

Please sign in to comment.