Skip to content

Commit

Permalink
Telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Aug 17, 2023
1 parent d7f954d commit 94f04b3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/client/pythonEnvironments/creation/provider/venvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Commands } from '../../../common/constants';
import { isWindows } from '../../../common/platform/platformService';
import { getVenvPath, hasVenv } from '../common/commonUtils';
import { deleteEnvironmentNonWindows, deleteEnvironmentWindows } from './venvDeleteUtils';
import { sendTelemetryEvent } from '../../../telemetry';
import { EventName } from '../../../telemetry/constants';

const exclude = '**/{.venv*,.git,.nox,.tox,.conda,site-packages,__pypackages__}/**';
async function getPipRequirementsFiles(
Expand Down Expand Up @@ -287,12 +289,23 @@ export async function pickExistingVenvAction(

if (selection.label === CreateEnv.Venv.recreate) {
if (await deleteEnvironment(workspaceFolder, interpreter)) {
sendTelemetryEvent(EventName.ENVIRONMENT_DELETE, undefined, {
environmentType: 'venv',
status: 'deleted',
});
return MultiStepAction.Continue;
}
sendTelemetryEvent(EventName.ENVIRONMENT_DELETE, undefined, {
environmentType: 'venv',
status: 'failed',
});
return MultiStepAction.Cancel;
}

if (selection.label === CreateEnv.Venv.useExisting) {
sendTelemetryEvent(EventName.ENVIRONMENT_REUSE, undefined, {
environmentType: 'venv',
});
return MultiStepAction.Continue;
}
} else if (context === MultiStepAction.Back) {
Expand Down
2 changes: 2 additions & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export enum EventName {
ENVIRONMENT_INSTALLED_PACKAGES = 'ENVIRONMENT.INSTALLED_PACKAGES',
ENVIRONMENT_INSTALLING_PACKAGES_FAILED = 'ENVIRONMENT.INSTALLING_PACKAGES_FAILED',
ENVIRONMENT_BUTTON = 'ENVIRONMENT.BUTTON',
ENVIRONMENT_DELETE = 'ENVIRONMENT.DELETE',
ENVIRONMENT_REUSE = 'ENVIRONMENT.REUSE',

TOOLS_EXTENSIONS_ALREADY_INSTALLED = 'TOOLS_EXTENSIONS.ALREADY_INSTALLED',
TOOLS_EXTENSIONS_PROMPT_SHOWN = 'TOOLS_EXTENSIONS.PROMPT_SHOWN',
Expand Down
24 changes: 24 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,30 @@ export interface IEventNamePropertyMapping {
"environment.button" : {"owner": "karthiknadig" }
*/
[EventName.ENVIRONMENT_BUTTON]: never | undefined;
/**
* Telemetry event if user selected to delete the existing environment.
*/
/* __GDPR__
"environment.delete" : {
"environmentType" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "owner": "karthiknadig" },
"status" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "owner": "karthiknadig" }
}
*/
[EventName.ENVIRONMENT_DELETE]: {
environmentType: 'venv' | 'conda';
status: 'deleted' | 'failed';
};
/**
* Telemetry event if user selected to re-use the existing environment.
*/
/* __GDPR__
"environment.reuse" : {
"environmentType" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "owner": "karthiknadig" }
}
*/
[EventName.ENVIRONMENT_REUSE]: {
environmentType: 'venv' | 'conda';
};
/**
* Telemetry event sent when a linter or formatter extension is already installed.
*/
Expand Down

0 comments on commit 94f04b3

Please sign in to comment.