From e48aee0375c9102735101416b91c519b24ae74d7 Mon Sep 17 00:00:00 2001 From: lcampos Date: Fri, 17 Aug 2018 12:58:19 -0700 Subject: [PATCH] Add metrics to commands being executed (#549) --- .../src/cli/commandBuilder.ts | 8 +++++++ .../src/cli/index.ts | 1 + .../src/commands/commands.ts | 6 +++++ .../src/commands/forceAliasList.ts | 1 + .../src/commands/forceApexClassCreate.ts | 4 ++-- .../src/commands/forceApexExecute.ts | 2 ++ .../src/commands/forceApexLogGet.ts | 3 +++ .../src/commands/forceApexTestRun.ts | 22 +++++++++++-------- .../commands/forceApexTestRunCodeAction.ts | 3 ++- .../src/commands/forceApexTriggerCreate.ts | 2 ++ .../src/commands/forceAuthDevHub.ts | 2 ++ .../src/commands/forceAuthLogout.ts | 1 + .../src/commands/forceAuthWebLogin.ts | 4 +++- .../src/commands/forceConfigList.ts | 1 + .../src/commands/forceDataSoqlQuery.ts | 7 ++++-- .../src/commands/forceDebuggerStop.ts | 3 +++ .../src/commands/forceGenerateFauxClasses.ts | 2 ++ .../src/commands/forceLightningAppCreate.ts | 2 ++ .../commands/forceLightningComponentCreate.ts | 2 ++ .../src/commands/forceLightningEventCreate.ts | 2 ++ .../commands/forceLightningInterfaceCreate.ts | 2 ++ .../src/commands/forceOrgCreate.ts | 1 + .../src/commands/forceOrgDisplay.ts | 3 ++- .../src/commands/forceOrgOpen.ts | 1 + .../src/commands/forceProjectCreate.ts | 4 +++- .../src/commands/forceSourceDeploy.ts | 3 ++- .../src/commands/forceSourcePull.ts | 3 ++- .../src/commands/forceSourcePush.ts | 3 ++- .../src/commands/forceSourceRetrieve.ts | 2 ++ .../src/commands/forceSourceStatus.ts | 5 ++++- .../commands/forceStartApexDebugLogging.ts | 15 ++++++++++--- .../src/commands/forceStopApexDebugLogging.ts | 4 ++++ .../forceVisualforceComponentCreate.ts | 2 ++ .../commands/forceVisualforcePageCreate.ts | 2 ++ .../src/commands/isvdebugging/bootstrapCmd.ts | 10 ++++++++- .../src/telemetry/telemetry.ts | 8 +++++-- .../src/commands/forceLightningLwcCreate.ts | 5 ++--- .../src/telemetry/telemetry.ts | 4 ++-- .../src/commands/forceLightningLwcCreate.ts | 3 ++- .../src/telemetry/telemetry.ts | 4 ++-- 40 files changed, 127 insertions(+), 35 deletions(-) diff --git a/packages/salesforcedx-utils-vscode/src/cli/commandBuilder.ts b/packages/salesforcedx-utils-vscode/src/cli/commandBuilder.ts index cb7ea98eff..4d84d3cda2 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/commandBuilder.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/commandBuilder.ts @@ -9,11 +9,13 @@ export class Command { public readonly command: string; public readonly description?: string; public readonly args: string[]; + public readonly logName?: string; public constructor(builder: CommandBuilder) { this.command = builder.command; this.description = builder.description; this.args = builder.args; + this.logName = builder.logName; } public toString(): string { @@ -31,6 +33,7 @@ export class CommandBuilder { public readonly command: string; public description?: string; public args: string[] = []; + public logName?: string; public constructor(command: string) { this.command = command; @@ -61,6 +64,11 @@ export class CommandBuilder { return this; } + public withLogName(logName: string): CommandBuilder { + this.logName = logName; + return this; + } + public build(): Command { return new Command(this); } diff --git a/packages/salesforcedx-utils-vscode/src/cli/index.ts b/packages/salesforcedx-utils-vscode/src/cli/index.ts index 03baba5e5b..500620d9c8 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/index.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/index.ts @@ -9,6 +9,7 @@ export interface Command { readonly command: string; readonly description?: string; readonly args: string[]; + readonly logName?: string; toString(): string; toCommand(): string; diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index acbd299630..d06c6e7735 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -26,6 +26,7 @@ import { nls } from '../messages'; import { notificationService, ProgressNotification } from '../notifications'; import { isSfdxProjectOpened } from '../predicates'; import { taskViewService } from '../statuses'; +import { telemetryService } from '../telemetry'; export class LightningFilePathExistsChecker implements PostconditionChecker { @@ -338,6 +339,10 @@ export abstract class SfdxCommandletExecutor taskViewService.addCommandExecution(execution, cancellationTokenSource); } + public logMetric(logName?: string) { + telemetryService.sendCommandEvent(logName); + } + public execute(response: ContinueResponse): void { const cancellationTokenSource = new vscode.CancellationTokenSource(); const cancellationToken = cancellationTokenSource.token; @@ -346,6 +351,7 @@ export abstract class SfdxCommandletExecutor }).execute(cancellationToken); this.attachExecution(execution, cancellationTokenSource, cancellationToken); + this.logMetric(execution.command.logName); } public abstract build(data: T): Command; diff --git a/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts b/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts index e6c85f6b8f..3b44e5b212 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts @@ -22,6 +22,7 @@ export class ForceAliasList extends SfdxCommandletExecutor<{}> { return new SfdxCommandBuilder() .withDescription(nls.localize('force_alias_list_text')) .withArg('force:alias:list') + .withLogName('force_alias_list') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts index 61b6e9c2af..2da8e76d06 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts @@ -21,7 +21,6 @@ import { channelService } from '../channels'; import { nls } from '../messages'; import { notificationService, ProgressNotification } from '../notifications'; import { taskViewService } from '../statuses'; -import { telemetryService } from '../telemetry'; import { CompositeParametersGatherer, FilePathExistsChecker, @@ -43,6 +42,7 @@ class ForceApexClassCreateExecutor extends SfdxCommandletExecutor< .withFlag('--classname', data.fileName) .withFlag('--template', 'DefaultApexClass') .withFlag('--outputdir', data.outputdir) + .withLogName('force_apex_class_create') .build(); } @@ -77,7 +77,7 @@ class ForceApexClassCreateExecutor extends SfdxCommandletExecutor< (execution.stderrSubject as any) as Observable ); - telemetryService.sendCommandEvent('force_apex_class_create'); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexExecute.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexExecute.ts index 1b7d52895f..a53d7e73d1 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexExecute.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexExecute.ts @@ -35,6 +35,7 @@ class ForceApexExecuteExecutor extends SfdxCommandletExecutor<{}> { .withDescription(nls.localize('force_apex_execute_document_text')) .withArg('force:apex:execute') .withFlag('--apexcodefile', data.fileName) + .withLogName('force_apex_execute') .build(); } @@ -54,6 +55,7 @@ class ForceApexExecuteExecutor extends SfdxCommandletExecutor<{}> { execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.showChannelOutput(); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexLogGet.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexLogGet.ts index 01e214d29d..8861164186 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexLogGet.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexLogGet.ts @@ -42,6 +42,7 @@ export class ForceApexLogGetExecutor extends SfdxCommandletExecutor< .withArg('force:apex:log:get') .withFlag('--logid', data.id) .withJson() + .withLogName('force_apex_log_get') .build(); } @@ -68,6 +69,7 @@ export class ForceApexLogGetExecutor extends SfdxCommandletExecutor< cwd: vscode.workspace.rootPath }).execute(cancellationToken); this.attachExecution(execution, cancellationTokenSource, cancellationToken); + this.logMetric(execution.command.logName); const result = await new CommandOutput().getCmdResult(execution); const resultJson = JSON.parse(result); if (resultJson.status === 0) { @@ -159,6 +161,7 @@ export class ForceApexLogList { .withDescription(nls.localize('force_apex_log_list_text')) .withArg('force:apex:log:list') .withJson() + .withLogName('force_apex_log_list') .build(), { cwd: vscode.workspace.workspaceFolders![0].uri.fsPath } ).execute(); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTestRun.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTestRun.ts index 544c073a09..889050df0c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTestRun.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTestRun.ts @@ -39,7 +39,7 @@ export class TestsSelector implements ParametersGatherer { public async gather(): Promise< CancelResponse | ContinueResponse - > { + > { const testSuites = await vscode.workspace.findFiles( '**/*.testSuite-meta.xml' ); @@ -96,12 +96,15 @@ export class ForceApexTestRunCommandFactory { public constructExecutorCommand(): Command { this.builder = this.builder .withDescription(nls.localize('force_apex_test_run_text')) - .withArg('force:apex:test:run'); + .withArg('force:apex:test:run') + .withLogName('force_apex_test_run'); switch (this.data.type) { case TestType.Suite: - this.builder = this.builder - .withFlag('--suitenames', `${this.data.label}`); + this.builder = this.builder.withFlag( + '--suitenames', + `${this.data.label}` + ); break; case TestType.Class: this.builder = this.builder @@ -113,8 +116,7 @@ export class ForceApexTestRunCommandFactory { } if (this.getCodeCoverage) { - this.builder = this.builder - .withArg('--codecoverage'); + this.builder = this.builder.withArg('--codecoverage'); } this.builder = this.builder @@ -124,17 +126,19 @@ export class ForceApexTestRunCommandFactory { this.testRunExecutorCommand = this.builder.build(); return this.testRunExecutorCommand; } - } export class ForceApexTestRunExecutor extends SfdxCommandletExecutor< ApexTestQuickPickItem - > { +> { public build(data: ApexTestQuickPickItem): Command { const getCodeCoverage: boolean = sfdxCoreSettings .getConfiguration() .get('retrieve-test-code-coverage') as boolean; - const factory: ForceApexTestRunCommandFactory = new ForceApexTestRunCommandFactory(data, getCodeCoverage); + const factory: ForceApexTestRunCommandFactory = new ForceApexTestRunCommandFactory( + data, + getCodeCoverage + ); return factory.constructExecutorCommand(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTestRunCodeAction.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTestRunCodeAction.ts index db25901c2a..7a45179d05 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTestRunCodeAction.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTestRunCodeAction.ts @@ -79,7 +79,8 @@ export class ForceApexTestRunCodeActionExecutor extends SfdxCommandletExecutor<{ .withFlag('--tests', this.test) .withFlag('--resultformat', 'human') .withArg('--synchronous') - .withFlag('--loglevel', 'error'); + .withFlag('--loglevel', 'error') + .withLogName('force_apex_test_run_code_action'); if (this.shouldGetCodeCoverage) { this.builder = this.builder.withArg('--codecoverage'); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts index c0db1198be..5d3c0f4717 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts @@ -42,6 +42,7 @@ export class ForceApexTriggerCreateExecutor extends SfdxCommandletExecutor< .withArg('force:apex:trigger:create') .withFlag('--triggername', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_apex_trigger_create') .build(); } @@ -78,6 +79,7 @@ export class ForceApexTriggerCreateExecutor extends SfdxCommandletExecutor< channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); + this.logMetric(execution.command.logName); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceAuthDevHub.ts b/packages/salesforcedx-vscode-core/src/commands/forceAuthDevHub.ts index 84f17b7c7b..a470ad49a8 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceAuthDevHub.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceAuthDevHub.ts @@ -29,6 +29,7 @@ export class ForceAuthDevHubExecutor extends SfdxCommandletExecutor<{}> { ) .withArg('force:auth:web:login') .withArg('--setdefaultdevhubusername') + .withLogName('force_auth_dev_hub') .build(); } } @@ -43,6 +44,7 @@ export class ForceAuthDevHubDemoModeExecutor extends ForceAuthDemoModeExecutor<{ .withArg('--setdefaultdevhubusername') .withArg('--noprompt') .withJson() + .withLogName('force_auth_dev_hub_demo_mode') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceAuthLogout.ts b/packages/salesforcedx-vscode-core/src/commands/forceAuthLogout.ts index 900eed00b9..e14cb77124 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceAuthLogout.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceAuthLogout.ts @@ -30,6 +30,7 @@ export class ForceAuthLogoutAll extends SfdxCommandletExecutor<{}> { .withArg('force:auth:logout') .withArg('--all') .withArg('--noprompt') + .withLogName('force_auth_logout') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceAuthWebLogin.ts b/packages/salesforcedx-vscode-core/src/commands/forceAuthWebLogin.ts index 6004911986..ac0ccf0eda 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceAuthWebLogin.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceAuthWebLogin.ts @@ -45,6 +45,7 @@ export class ForceAuthWebLoginExecutor extends SfdxCommandletExecutor { .withArg('force:auth:web:login') .withFlag('--setalias', data.alias) .withArg('--setdefaultusername') + .withLogName('force_auth_web_login') .build(); } } @@ -64,7 +65,7 @@ export abstract class ForceAuthDemoModeExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); - + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); @@ -96,6 +97,7 @@ export class ForceAuthWebLoginDemoModeExecutor extends ForceAuthDemoModeExecutor .withArg('--setdefaultusername') .withArg('--noprompt') .withJson() + .withLogName('force_auth_web_login_demo_mode') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts b/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts index 0855bab1a9..3fc5d21589 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts @@ -22,6 +22,7 @@ export class ForceConfigList extends SfdxCommandletExecutor<{}> { return new SfdxCommandBuilder() .withDescription(nls.localize('force_config_list_text')) .withArg('force:config:list') + .withLogName('force_config_list') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceDataSoqlQuery.ts b/packages/salesforcedx-vscode-core/src/commands/forceDataSoqlQuery.ts index 6fd79ae935..1d4f6852cf 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceDataSoqlQuery.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceDataSoqlQuery.ts @@ -27,9 +27,12 @@ class ForceDataSoqlQueryExecutor extends SfdxCommandletExecutor<{}> { let command = new SfdxCommandBuilder() .withDescription(nls.localize('force_data_soql_query_input_text')) .withArg('force:data:soql:query') - .withFlag('--query', `${data.query}`); + .withFlag('--query', `${data.query}`) + .withLogName('force_data_soql_query'); if (data.api === ApiType.Tooling) { - command = command.withArg('--usetoolingapi'); + command = command + .withArg('--usetoolingapi') + .withLogName('force_data_soql_query_tooling'); } return command.build(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceDebuggerStop.ts b/packages/salesforcedx-vscode-core/src/commands/forceDebuggerStop.ts index c6943b037b..cdf0b5e874 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceDebuggerStop.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceDebuggerStop.ts @@ -66,6 +66,7 @@ export class DebuggerSessionDetachExecutor extends SfdxCommandletExecutor< .withFlag('--sobjectid', data ? data.id : '') .withFlag('--values', 'Status="Detach"') .withArg('--usetoolingapi') + .withLogName('force_debugger_stop') .build(); } } @@ -81,6 +82,7 @@ export class StopActiveDebuggerSessionExecutor extends SfdxCommandletExecutor<{} ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_debugger_query_session') .build(); } @@ -93,6 +95,7 @@ export class StopActiveDebuggerSessionExecutor extends SfdxCommandletExecutor<{} }).execute(cancellationToken); const resultPromise = new CommandOutput().getCmdResult(execution); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); channelService.showChannelOutput(); ProgressNotification.show(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceGenerateFauxClasses.ts b/packages/salesforcedx-vscode-core/src/commands/forceGenerateFauxClasses.ts index 6f1df6b170..0195d2a1b7 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceGenerateFauxClasses.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceGenerateFauxClasses.ts @@ -28,6 +28,7 @@ class ForceGenerateFauxClassesExecutor extends SfdxCommandletExecutor<{}> { return new SfdxCommandBuilder() .withDescription(nls.localize('force_sobjects_refresh')) .withArg('sobject definitions refresh') + .withLogName('force_generate_faux_classes_create') .build(); } @@ -59,6 +60,7 @@ class ForceGenerateFauxClassesExecutor extends SfdxCommandletExecutor<{}> { console.log('Generate error ' + e); } ForceGenerateFauxClassesExecutor.isActive = false; + this.logMetric(execution.command.logName); return; } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts index a059c91f7a..6ef4a2a6d1 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts @@ -42,6 +42,7 @@ class ForceLightningAppCreateExecutor extends SfdxCommandletExecutor< .withArg('force:lightning:app:create') .withFlag('--appname', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_app_create') .build(); } @@ -77,6 +78,7 @@ class ForceLightningAppCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts index 4351e9cb8e..318565576e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts @@ -42,6 +42,7 @@ class ForceLightningComponentCreateExecutor extends SfdxCommandletExecutor< .withArg('force:lightning:component:create') .withFlag('--componentname', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_component_create') .build(); } @@ -77,6 +78,7 @@ class ForceLightningComponentCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts index f7ba9682c2..cda19f2fd7 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts @@ -42,6 +42,7 @@ class ForceLightningEventCreateExecutor extends SfdxCommandletExecutor< .withArg('force:lightning:event:create') .withFlag('--eventname', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_event_create') .build(); } @@ -77,6 +78,7 @@ class ForceLightningEventCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts index e7de13e4b7..2905c92931 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts @@ -42,6 +42,7 @@ class ForceLightningInterfaceCreateExecutor extends SfdxCommandletExecutor< .withArg('force:lightning:interface:create') .withFlag('--interfacename', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_interface_create') .build(); } @@ -77,6 +78,7 @@ class ForceLightningInterfaceCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceOrgCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceOrgCreate.ts index b7309cb899..82784da186 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceOrgCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceOrgCreate.ts @@ -43,6 +43,7 @@ export class ForceOrgCreateExecutor extends SfdxCommandletExecutor< .withFlag('-f', `${selectionPath}`) .withFlag('--setalias', data.alias) .withArg('--setdefaultusername') + .withLogName('force_org_create_default_scratch_org') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts b/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts index ffa4bc4b5c..8d6e3e124e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts @@ -30,7 +30,8 @@ export class ForceOrgDisplay extends SfdxCommandletExecutor<{}> { public build(data: { username?: string }): Command { const builder = new SfdxCommandBuilder() .withDescription(nls.localize('force_org_display_default_text')) - .withArg('force:org:display'); + .withArg('force:org:display') + .withLogName('force_org_display_default'); if (this.flag === '--targetusername' && data.username) { builder .withDescription(nls.localize('force_org_display_username_text')) diff --git a/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts b/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts index 0b4e08f9b5..39aa344590 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts @@ -22,6 +22,7 @@ class ForceOrgOpenExecutor extends SfdxCommandletExecutor<{}> { return new SfdxCommandBuilder() .withDescription(nls.localize('force_org_open_default_scratch_org_text')) .withArg('force:org:open') + .withLogName('force_org_open_default_scratch_org') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceProjectCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceProjectCreate.ts index f69ed12a2e..2ededef1c6 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceProjectCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceProjectCreate.ts @@ -50,7 +50,8 @@ export class ForceProjectCreateExecutor extends SfdxCommandletExecutor< .withDescription(nls.localize('force_project_create_text')) .withArg('force:project:create') .withFlag('--projectname', data.projectName) - .withFlag('--outputdir', data.projectUri); + .withFlag('--outputdir', data.projectUri) + .withLogName('force_project_create'); if (this.options.isProjectWithManifest) { builder.withArg('--manifest'); @@ -82,6 +83,7 @@ export class ForceProjectCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourceDeploy.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourceDeploy.ts index 742fb62456..119d92045a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourceDeploy.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourceDeploy.ts @@ -27,7 +27,8 @@ export class ForceSourceDeployExecutor extends SfdxCommandletExecutor< public build(data: SelectedPath): Command { const commandBuilder = new SfdxCommandBuilder() .withDescription(nls.localize('force_source_deploy_text')) - .withArg('force:source:deploy'); + .withArg('force:source:deploy') + .withLogName('force_source_deploy'); if (data.type === FileType.Manifest) { commandBuilder.withFlag('--manifest', data.filePath); } else { diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts index a931c5a058..9cf3698be9 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts @@ -30,7 +30,8 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> { .withDescription( nls.localize('force_source_pull_default_scratch_org_text') ) - .withArg('force:source:pull'); + .withArg('force:source:pull') + .withLogName('force_source_pull_default_scratch_org'); if (this.flag === '--forceoverwrite') { builder .withArg(this.flag) diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourcePush.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourcePush.ts index 40f19f03ab..aa892dcf87 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourcePush.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourcePush.ts @@ -30,7 +30,8 @@ export class ForceSourcePushExecutor extends SfdxCommandletExecutor<{}> { .withDescription( nls.localize('force_source_push_default_scratch_org_text') ) - .withArg('force:source:push'); + .withArg('force:source:push') + .withLogName('force_source_push_default_scratch_org'); if (this.flag === '--forceoverwrite') { builder.withArg(this.flag); builder.withDescription( diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts index e7bdad4964..6d0ee405b2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts @@ -33,8 +33,10 @@ export class ForceSourceRetrieveExecutor extends SfdxCommandletExecutor< .withArg('force:source:retrieve'); if (data.type === FileType.Manifest) { commandBuilder.withFlag('--manifest', data.filePath); + commandBuilder.withLogName('force_source_retrieve_with_manifest'); } else { commandBuilder.withFlag('--sourcepath', data.filePath); + commandBuilder.withLogName('force_source_retrieve_with_sourcepath'); } return commandBuilder.build(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts index b62ad16723..9c72807c36 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts @@ -34,13 +34,16 @@ export class ForceSourceStatusExecutor extends SfdxCommandletExecutor<{}> { public build(data: {}): Command { const builder = new SfdxCommandBuilder() .withDescription(nls.localize('force_source_status_text')) - .withArg('force:source:status'); + .withArg('force:source:status') + .withLogName('force_source_status'); if (this.flag === SourceStatusFlags.Local) { builder.withArg(this.flag); builder.withDescription(nls.localize('force_source_status_local_text')); + builder.withLogName('force_source_status_local'); } else if (this.flag === SourceStatusFlags.Remote) { builder.withArg(this.flag); builder.withDescription(nls.localize('force_source_status_remote_text')); + builder.withLogName('force_source_status_remote'); } return builder.build(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceStartApexDebugLogging.ts b/packages/salesforcedx-vscode-core/src/commands/forceStartApexDebugLogging.ts index 6e799c3612..4e76a9c633 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceStartApexDebugLogging.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceStartApexDebugLogging.ts @@ -26,6 +26,7 @@ import { SfdxWorkspaceChecker } from './commands'; +import { telemetryService } from '../telemetry'; import { developerLogTraceFlag } from './'; export class ForceStartApexDebugLoggingExecutor extends SfdxCommandletExecutor<{}> { @@ -33,9 +34,9 @@ export class ForceStartApexDebugLoggingExecutor extends SfdxCommandletExecutor<{ private cancellationToken = this.cancellationTokenSource.token; public build(): Command { - return new CommandBuilder( - nls.localize('force_start_apex_debug_logging') - ).build(); + return new CommandBuilder(nls.localize('force_start_apex_debug_logging')) + .withLogName('force_start_apex_debug_logging') + .build(); } public attachSubExecution(execution: CommandExecution) { @@ -52,6 +53,7 @@ export class ForceStartApexDebugLoggingExecutor extends SfdxCommandletExecutor<{ this.cancellationToken ); + this.logMetric(executionWrapper.command.logName); try { // query traceflag let resultJson = await this.subExecute(new ForceQueryTraceFlag().build()); @@ -106,9 +108,11 @@ export async function getUserId(projectPath: string): Promise { new SfdxCommandBuilder() .withArg('force:user:display') .withJson() + .withLogName('force_user_display') .build(), { cwd: projectPath } ).execute(); + telemetryService.sendCommandEvent(execution.command.logName); const cmdOutput = new CommandOutput(); const result = await cmdOutput.getCmdResult(execution); try { @@ -132,6 +136,7 @@ export class CreateDebugLevel extends SfdxCommandletExecutor<{}> { ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_create_debug_level') .build(); } } @@ -159,6 +164,7 @@ export class CreateTraceFlag extends SfdxCommandletExecutor<{}> { ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_create_trace_flag') .build(); } } @@ -176,6 +182,7 @@ export class UpdateDebugLevelsExecutor extends SfdxCommandletExecutor<{}> { ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_update_debug_level') .build(); } } @@ -197,6 +204,7 @@ export class UpdateTraceFlagsExecutor extends SfdxCommandletExecutor<{}> { ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_update_trace_flag') .build(); } } @@ -215,6 +223,7 @@ export class ForceQueryTraceFlag extends SfdxCommandletExecutor<{}> { ) .withArg('--usetoolingapi') .withJson() + .withLogName('force_query_trace_flag') .build(); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceStopApexDebugLogging.ts b/packages/salesforcedx-vscode-core/src/commands/forceStopApexDebugLogging.ts index 75a0c373fb..419f37e7c1 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceStopApexDebugLogging.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceStopApexDebugLogging.ts @@ -20,6 +20,7 @@ import * as vscode from 'vscode'; import { developerLogTraceFlag } from '.'; import { hideTraceFlagExpiration } from '../decorators'; import { nls } from '../messages'; +import { telemetryService } from '../telemetry'; import { SfdxCommandlet, SfdxCommandletExecutor, @@ -40,6 +41,7 @@ export class ForceStopApexDebugLoggingExecutor extends SfdxCommandletExecutor<{} }).execute(cancellationToken); this.attachExecution(execution, cancellationTokenSource, cancellationToken); + this.logMetric(execution.command.logName); execution.processExitSubject.subscribe(async data => { if (data !== undefined && data.toString() === '0') { developerLogTraceFlag.turnOffLogging(); @@ -54,6 +56,7 @@ export async function turnOffLogging(): Promise { const execution = new CliCommandExecutor(deleteTraceFlag(), { cwd: vscode.workspace.rootPath }).execute(); + telemetryService.sendCommandEvent(execution.command.logName); const resultPromise = new CommandOutput().getCmdResult(execution); const result = await resultPromise; const resultJson = JSON.parse(result); @@ -73,6 +76,7 @@ function deleteTraceFlag(): Command { .withFlag('--sobjecttype', 'TraceFlag') .withFlag('--sobjectid', nonNullTraceFlag) .withArg('--usetoolingapi') + .withLogName('force_stop_apex_debug_logging') .build(); } class ActiveLogging implements ParametersGatherer<{}> { diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts index 8a5072546b..d16e3d77a4 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts @@ -43,6 +43,7 @@ class ForceVisualForceComponentCreateExecutor extends SfdxCommandletExecutor< .withFlag('--componentname', data.fileName) .withFlag('--label', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_visualforce_component_create') .build(); } @@ -76,6 +77,7 @@ class ForceVisualForceComponentCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts index 9536d68697..5bf5ace6a6 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts @@ -43,6 +43,7 @@ class ForceVisualForcePageCreateExecutor extends SfdxCommandletExecutor< .withFlag('--pagename', data.fileName) .withFlag('--label', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_visualforce_page_create') .build(); } @@ -76,6 +77,7 @@ class ForceVisualForcePageCreateExecutor extends SfdxCommandletExecutor< execution.command.toString(), (execution.stderrSubject as any) as Observable ); + this.logMetric(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-core/src/commands/isvdebugging/bootstrapCmd.ts b/packages/salesforcedx-vscode-core/src/commands/isvdebugging/bootstrapCmd.ts index 0153665098..d49170191e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/isvdebugging/bootstrapCmd.ts +++ b/packages/salesforcedx-vscode-core/src/commands/isvdebugging/bootstrapCmd.ts @@ -88,6 +88,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withArg('force:project:create') .withFlag('--projectname', data.projectName) .withFlag('--outputdir', data.projectUri) + .withLogName('isv_debug_bootstrap_create_project') .build(); } @@ -100,6 +101,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withArg(`isvDebuggerSid=${data.sessionId}`) .withArg(`isvDebuggerUrl=${data.loginUrl}`) .withArg(`instanceUrl=${data.loginUrl}`) + .withLogName('isv_debug_bootstrap_configure_project') .build(); } @@ -116,6 +118,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withFlag('--query', 'SELECT NamespacePrefix FROM Organization LIMIT 1') .withFlag('--targetusername', data.sessionId) .withJson() + .withLogName('isv_debug_bootstrap_configure_project_retrieve_namespace') .build(); } @@ -144,6 +147,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withFlag('--retrievetargetdir', this.relativeMetdataTempPath) .withFlag('--unpackaged', this.relativeApexPackageXmlPath) .withFlag('--targetusername', data.sessionId) + .withLogName('isv_debug_bootstrap_retrieve_org_source') .build(); } @@ -160,6 +164,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { path.join(this.relativeMetdataTempPath, 'unpackaged') ) .withFlag('--outputdir', 'force-app') + .withLogName('isv_debug_bootstrap_convert_org_source') .build(); } @@ -173,6 +178,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withArg('force:package:installed:list') .withFlag('--targetusername', data.sessionId) .withJson() + .withLogName('isv_debug_bootstrap_list_installed_packages') .build(); } @@ -188,6 +194,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { .withFlag('--retrievetargetdir', this.relativeMetdataTempPath) .withFlag('--packagenames', packageNames.join(',')) .withFlag('--targetusername', data.sessionId) + .withLogName('isv_debug_bootstrap_retrieve_packages_source') .build(); } @@ -210,6 +217,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { '--outputdir', path.join(this.relativeInstalledPackagesPath, packageName) ) + .withLogName('isv_debug_bootstrap_convert_package_source') .build(); } @@ -512,7 +520,7 @@ export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { const result = new CommandOutput().getCmdResult(execution); this.attachExecution(execution, cancellationTokenSource, cancellationToken); - + this.logMetric(execution.command.logName); return result; } diff --git a/packages/salesforcedx-vscode-core/src/telemetry/telemetry.ts b/packages/salesforcedx-vscode-core/src/telemetry/telemetry.ts index 5eeaface9e..4426a079f9 100644 --- a/packages/salesforcedx-vscode-core/src/telemetry/telemetry.ts +++ b/packages/salesforcedx-vscode-core/src/telemetry/telemetry.ts @@ -119,8 +119,12 @@ export class TelemetryService { } } - public sendCommandEvent(commandName: string): void { - if (this.reporter !== undefined && this.isTelemetryEnabled()) { + public sendCommandEvent(commandName?: string): void { + if ( + this.reporter !== undefined && + this.isTelemetryEnabled() && + commandName + ) { this.reporter.sendTelemetryEvent('commandExecution', { extensionName: EXTENSION_NAME, commandName diff --git a/packages/salesforcedx-vscode-lwc-next/src/commands/forceLightningLwcCreate.ts b/packages/salesforcedx-vscode-lwc-next/src/commands/forceLightningLwcCreate.ts index 24e7533fe0..ea5b02789c 100644 --- a/packages/salesforcedx-vscode-lwc-next/src/commands/forceLightningLwcCreate.ts +++ b/packages/salesforcedx-vscode-lwc-next/src/commands/forceLightningLwcCreate.ts @@ -83,6 +83,7 @@ class ForceLightningLwcCreateExecutor extends (SfdxCommandletExecutor as { .withFlag('--type', 'lwc') .withFlag('--componentname', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_component_create') .build(); } @@ -118,9 +119,7 @@ class ForceLightningLwcCreateExecutor extends (SfdxCommandletExecutor as { execution.command.toString(), (execution.stderrSubject as any) as Observable ); - telemetryService.sendCommandEvent( - 'force_lightning_lwc_next_component_create' - ); + telemetryService.sendCommandEvent(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-lwc-next/src/telemetry/telemetry.ts b/packages/salesforcedx-vscode-lwc-next/src/telemetry/telemetry.ts index c6da63b70f..8b6dfee452 100644 --- a/packages/salesforcedx-vscode-lwc-next/src/telemetry/telemetry.ts +++ b/packages/salesforcedx-vscode-lwc-next/src/telemetry/telemetry.ts @@ -48,8 +48,8 @@ export class TelemetryService { } } - public sendCommandEvent(commandName: string): void { - if (this.reporter !== undefined && this.isTelemetryEnabled) { + public sendCommandEvent(commandName?: string): void { + if (this.reporter !== undefined && this.isTelemetryEnabled && commandName) { this.reporter.sendTelemetryEvent('commandExecution', { extensionName: EXTENSION_NAME, commandName diff --git a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts index 8ad392fdcc..0cccdcc0ac 100644 --- a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts +++ b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts @@ -83,6 +83,7 @@ class ForceLightningLwcCreateExecutor extends (SfdxCommandletExecutor as { .withFlag('--type', 'web') .withFlag('--componentname', data.fileName) .withFlag('--outputdir', data.outputdir) + .withLogName('force_lightning_component_create') .build(); } @@ -118,7 +119,7 @@ class ForceLightningLwcCreateExecutor extends (SfdxCommandletExecutor as { execution.command.toString(), (execution.stderrSubject as any) as Observable ); - telemetryService.sendCommandEvent('force_lightning_lwc_component_create'); + telemetryService.sendCommandEvent(execution.command.logName); channelService.streamCommandOutput(execution); ProgressNotification.show(execution, cancellationTokenSource); taskViewService.addCommandExecution(execution, cancellationTokenSource); diff --git a/packages/salesforcedx-vscode-lwc/src/telemetry/telemetry.ts b/packages/salesforcedx-vscode-lwc/src/telemetry/telemetry.ts index cf7c7767a9..8de2c2bb9c 100644 --- a/packages/salesforcedx-vscode-lwc/src/telemetry/telemetry.ts +++ b/packages/salesforcedx-vscode-lwc/src/telemetry/telemetry.ts @@ -48,8 +48,8 @@ export class TelemetryService { } } - public sendCommandEvent(commandName: string): void { - if (this.reporter !== undefined && this.isTelemetryEnabled) { + public sendCommandEvent(commandName?: string): void { + if (this.reporter !== undefined && this.isTelemetryEnabled && commandName) { this.reporter.sendTelemetryEvent('commandExecution', { extensionName: EXTENSION_NAME, commandName