Skip to content

Commit 1406dac

Browse files
authored
Ensure file names are not captured when sending telemetry for unit tests (microsoft#3768)
For microsoft#3767
1 parent 674fd84 commit 1406dac

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

news/2 Fixes/3767.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure file names are not captured when sending telemetry for unit tests.

src/client/telemetry/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export type TestRunTelemetry = {
7272
tool: 'nosetest' | 'pytest' | 'unittest';
7373
scope: 'currentFile' | 'all' | 'file' | 'class' | 'function' | 'failed';
7474
debugging: boolean;
75-
triggeredBy: 'ui' | 'codelens' | 'commandpalette' | 'auto';
75+
triggerSource: 'ui' | 'codelens' | 'commandpalette' | 'auto';
7676
failed: boolean;
7777
};
7878
export type TestDiscoverytTelemetry = {

src/client/unittests/common/managers/baseTestManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CancellationToken, CancellationTokenSource, Disposable, OutputChannel,
22
import { IWorkspaceService } from '../../../common/application/types';
33
import { isNotInstalledError } from '../../../common/helpers';
44
import { IConfigurationService, IDisposableRegistry, IInstaller, IOutputChannel, IPythonSettings, Product } from '../../../common/types';
5+
import { getNamesAndValues } from '../../../common/utils/enum';
56
import { IServiceContainer } from '../../../ioc/types';
67
import { UNITTEST_DISCOVER, UNITTEST_RUN } from '../../../telemetry/constants';
78
import { sendTelemetryEvent } from '../../../telemetry/index';
@@ -171,11 +172,13 @@ export abstract class BaseTestManager implements ITestManager {
171172
Run_Specific_Class: 'false',
172173
Run_Specific_Function: 'false'
173174
};
175+
//Ensure valid values are sent.
176+
const validCmdSourceValues = getNamesAndValues<CommandSource>(CommandSource).map(item => item.value);
174177
const telementryProperties: TestRunTelemetry = {
175178
tool: this.testProvider,
176179
scope: 'all',
177180
debugging: debug === true,
178-
triggeredBy: cmdSource,
181+
triggerSource: validCmdSourceValues.indexOf(cmdSource) === -1 ? 'commandpalette' : cmdSource,
179182
failed: false
180183
};
181184
if (runFailedTests === true) {

0 commit comments

Comments
 (0)