Skip to content

Commit 7dfa631

Browse files
authored
Add telemetry event when creating environment using button (#21172)
A temporary command to understand the usage of the create environment button. Fixes #21168
1 parent f5eded2 commit 7dfa631

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@
277277
"command": "python.createEnvironment",
278278
"title": "%python.command.python.createEnvironment.title%"
279279
},
280+
{
281+
"category": "Python",
282+
"command": "python.createEnvironment-button",
283+
"title": "%python.command.python.createEnvironment.title%"
284+
},
280285
{
281286
"category": "Python",
282287
"command": "python.enableLinting",
@@ -1700,12 +1705,12 @@
17001705
"editor/content": [
17011706
{
17021707
"group": "Python",
1703-
"command": "python.createEnvironment",
1708+
"command": "python.createEnvironment-button",
17041709
"when": "resourceLangId == pip-requirements && !virtualWorkspace && shellExecutionSupported && !inDiffEditor"
17051710
},
17061711
{
17071712
"group": "Python",
1708-
"command": "python.createEnvironment",
1713+
"command": "python.createEnvironment-button",
17091714
"when": "resourceFilename == pyproject.toml && pipInstallableToml && !virtualWorkspace && shellExecutionSupported && !inDiffEditor"
17101715
}
17111716
],

src/client/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export namespace Commands {
3737
export const CreateNewFile = 'python.createNewFile';
3838
export const ClearWorkspaceInterpreter = 'python.clearWorkspaceInterpreter';
3939
export const Create_Environment = 'python.createEnvironment';
40+
export const Create_Environment_Button = 'python.createEnvironment-button';
4041
export const Create_Terminal = 'python.createTerminal';
4142
export const Debug_In_Terminal = 'python.debugInTerminal';
4243
export const Enable_Linter = 'python.enableLinting';

src/client/pythonEnvironments/creation/createEnvApi.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { ConfigurationTarget, Disposable } from 'vscode';
55
import { Commands } from '../../common/constants';
66
import { IDisposableRegistry, IInterpreterPathService, IPathUtils } from '../../common/types';
7-
import { registerCommand } from '../../common/vscodeApis/commandApis';
7+
import { executeCommand, registerCommand } from '../../common/vscodeApis/commandApis';
88
import { IInterpreterQuickPick } from '../../interpreter/configuration/types';
99
import { getCreationEvents, handleCreateEnvironmentCommand } from './createEnvironment';
1010
import { condaCreationProvider } from './provider/condaCreationProvider';
@@ -18,6 +18,8 @@ import {
1818
ProposedCreateEnvironmentAPI,
1919
EnvironmentDidCreateEvent,
2020
} from './proposed.createEnvApis';
21+
import { sendTelemetryEvent } from '../../telemetry';
22+
import { EventName } from '../../telemetry/constants';
2123

2224
class CreateEnvironmentProviders {
2325
private _createEnvProviders: CreateEnvironmentProvider[] = [];
@@ -67,6 +69,13 @@ export function registerCreateEnvironmentFeatures(
6769
return handleCreateEnvironmentCommand(providers, options);
6870
},
6971
),
72+
registerCommand(
73+
Commands.Create_Environment_Button,
74+
async (): Promise<void> => {
75+
sendTelemetryEvent(EventName.ENVIRONMENT_BUTTON, undefined, undefined);
76+
await executeCommand(Commands.Create_Environment);
77+
},
78+
),
7079
registerCreateEnvironmentProvider(new VenvCreationProvider(interpreterQuickPick)),
7180
registerCreateEnvironmentProvider(condaCreationProvider()),
7281
onCreateEnvironmentExited(async (e: EnvironmentDidCreateEvent) => {

src/client/telemetry/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export enum EventName {
111111
ENVIRONMENT_INSTALLING_PACKAGES = 'ENVIRONMENT.INSTALLING_PACKAGES',
112112
ENVIRONMENT_INSTALLED_PACKAGES = 'ENVIRONMENT.INSTALLED_PACKAGES',
113113
ENVIRONMENT_INSTALLING_PACKAGES_FAILED = 'ENVIRONMENT.INSTALLING_PACKAGES_FAILED',
114+
ENVIRONMENT_BUTTON = 'ENVIRONMENT.BUTTON',
114115

115116
TOOLS_EXTENSIONS_ALREADY_INSTALLED = 'TOOLS_EXTENSIONS.ALREADY_INSTALLED',
116117
TOOLS_EXTENSIONS_PROMPT_SHOWN = 'TOOLS_EXTENSIONS.PROMPT_SHOWN',

src/client/telemetry/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,13 @@ export interface IEventNamePropertyMapping {
20982098
environmentType: 'venv' | 'conda' | 'microvenv';
20992099
using: 'pipUpgrade' | 'requirements.txt' | 'pyproject.toml' | 'environment.yml' | 'pipDownload' | 'pipInstall';
21002100
};
2101+
/**
2102+
* Telemetry event sent if create environment button was used to trigger the command.
2103+
*/
2104+
/* __GDPR__
2105+
"environment.button" : {"owner": "karthiknadig" }
2106+
*/
2107+
[EventName.ENVIRONMENT_BUTTON]: never | undefined;
21012108
/**
21022109
* Telemetry event sent when a linter or formatter extension is already installed.
21032110
*/

0 commit comments

Comments
 (0)