Skip to content

Add telemetry to report issue command #17506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/client/common/application/commands/reportIssueCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -69,9 +71,10 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
this.workspaceService.getConfiguration('python').get<string>('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, {});
}
}
1 change: 1 addition & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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();
});
});