From 3416fb8bd83004c4430df3de9922b60419744c73 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 23 Sep 2021 10:36:43 -0700 Subject: [PATCH 1/3] Add telemtry event --- src/client/telemetry/constants.ts | 1 + src/client/telemetry/index.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index 3360e4648d8d..85e4b9831e16 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -95,6 +95,7 @@ export enum EventName { PLATFORM_INFO = 'PLATFORM.INFO', SELECT_LINTER = 'LINTING.SELECT', + USE_REPORT_ISSUE_COMMAND = 'USE_REPORT_ISSUE_COMMAND', LINTER_NOT_INSTALLED_PROMPT = 'LINTER_NOT_INSTALLED_PROMPT', LINTER_INSTALL_PROMPT = 'LINTER_INSTALL_PROMPT', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index d83776f6b1e2..c158e636f4f4 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1249,6 +1249,10 @@ export interface IEventNamePropertyMapping { * Telemetry event sent when the experiments service is initialized for the first time. */ [EventName.PYTHON_EXPERIMENTS_INIT_PERFORMANCE]: unknown; + /** + * Telemetry event sent when the user use the report issue command. + */ + [EventName.USE_REPORT_ISSUE_COMMAND]: unknown; /** * Telemetry event sent once on session start with details on which experiments are opted into and opted out from. */ From e0ce699dbc5fafd114901d80980dd9df2ff1b481 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 23 Sep 2021 11:02:02 -0700 Subject: [PATCH 2/3] Add telemetry event in report issue command --- src/client/common/application/commands/reportIssueCommand.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index ffd70934a5f4..ae68c615aa8a 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -14,6 +14,8 @@ import { IInterpreterService, IInterpreterVersionService } from '../../../interp import { identifyEnvironment } from '../../../pythonEnvironments/common/environmentIdentifier'; import { Commands } from '../../constants'; import { IConfigurationService, IPythonSettings } from '../../types'; +import { sendTelemetryEvent } from '../../../telemetry'; +import { EventName } from '../../../telemetry/constants'; /** * Allows the user to report an issue related to the Python extension using our template. @@ -69,9 +71,10 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ this.workspaceService.getConfiguration('python').get('languageServer') || 'Not Found'; const virtualEnv = await identifyEnvironment(interpreterPath); - this.commandManager.executeCommand('workbench.action.openIssueReporter', { + await this.commandManager.executeCommand('workbench.action.openIssueReporter', { extensionId: 'ms-python.python', issueBody: template.format(pythonVersion, virtualEnv, languageServer, userSettings), }); + sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); } } From 6065d1d1ad1f632762a109ef355e7361135724ab Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 23 Sep 2021 11:12:24 -0700 Subject: [PATCH 3/3] Add test for Telemetry event --- .../application/commands/reportIssueCommand.unit.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index 524afb34488d..9f4614985234 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -8,6 +8,7 @@ import * as fs from 'fs-extra'; import * as path from 'path'; import { anything, capture, instance, mock, verify, when } from 'ts-mockito'; import { expect } from 'chai'; +import * as Telemetry from '../../../../client/telemetry'; import { LanguageServerType } from '../../../../client/activation/types'; import { CommandManager } from '../../../../client/common/application/commandManager'; import { ReportIssueCommandHandler } from '../../../../client/common/application/commands/reportIssueCommand'; @@ -25,6 +26,7 @@ import { Commands } from '../../../../client/common/constants'; import { AllCommands } from '../../../../client/common/application/commands'; import { ConfigurationService } from '../../../../client/common/configuration/service'; import { IConfigurationService } from '../../../../client/common/types'; +import { EventName } from '../../../../client/telemetry/constants'; suite('Report Issue Command', () => { let reportIssueCommandHandler: ReportIssueCommandHandler; @@ -109,4 +111,11 @@ suite('Report Issue Command', () => { const actual = args[1].issueBody; expect(actual).to.be.equal(expectedIssueBody); }); + test('Should send telemetry event when run Report Issue Command', async () => { + const sendTelemetryStub = sinon.stub(Telemetry, 'sendTelemetryEvent'); + await reportIssueCommandHandler.openReportIssue(); + + sinon.assert.calledWith(sendTelemetryStub, EventName.USE_REPORT_ISSUE_COMMAND); + sinon.restore(); + }); });