Skip to content

Commit efc5101

Browse files
authored
update telemetry events to support envs ext (#25277)
fixes for the following events: `execution_code"` `environment.created"` `environment.creating"` `python_interpreter_activation_for_terminal`
1 parent 81f3397 commit efc5101

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/client/common/terminal/activator/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { ITerminalActivationHandler, ITerminalActivator, ITerminalHelper, Termin
1010
import { BaseTerminalActivator } from './base';
1111
import { inTerminalEnvVarExperiment } from '../../experiments/helpers';
1212
import { useEnvExtension } from '../../../envExt/api.internal';
13+
import { EventName } from '../../../telemetry/constants';
14+
import { sendTelemetryEvent } from '../../../telemetry';
1315

1416
@injectable()
1517
export class TerminalActivator implements ITerminalActivator {
@@ -43,6 +45,9 @@ export class TerminalActivator implements ITerminalActivator {
4345
const activateEnvironment =
4446
settings.terminal.activateEnvironment && !inTerminalEnvVarExperiment(this.experimentService);
4547
if (!activateEnvironment || options?.hideFromUser || useEnvExtension()) {
48+
if (useEnvExtension()) {
49+
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_ACTIVATION_FOR_TERMINAL);
50+
}
4651
return false;
4752
}
4853

src/client/pythonEnvironments/creation/createEnvApi.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,28 @@ export function registerCreateEnvironmentFeatures(
7272
): Promise<CreateEnvironmentResult | undefined> => {
7373
if (useEnvExtension()) {
7474
try {
75+
sendTelemetryEvent(EventName.ENVIRONMENT_CREATING, undefined, {
76+
environmentType: undefined,
77+
pythonVersion: undefined,
78+
});
7579
const result = await executeCommand<PythonEnvironment | undefined>(
7680
'python-envs.createAny',
7781
options,
7882
);
7983
if (result) {
84+
const managerId = result.envId.managerId;
85+
if (managerId === 'ms-python.python:venv') {
86+
sendTelemetryEvent(EventName.ENVIRONMENT_CREATED, undefined, {
87+
environmentType: 'venv',
88+
reason: 'created',
89+
});
90+
}
91+
if (managerId === 'ms-python.python:conda') {
92+
sendTelemetryEvent(EventName.ENVIRONMENT_CREATED, undefined, {
93+
environmentType: 'conda',
94+
reason: 'created',
95+
});
96+
}
8097
return { path: result.environmentPath.path };
8198
}
8299
} catch (err) {

src/client/telemetry/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,7 @@ export interface IEventNamePropertyMapping {
23362336
}
23372337
*/
23382338
[EventName.ENVIRONMENT_CREATING]: {
2339-
environmentType: 'venv' | 'conda' | 'microvenv';
2339+
environmentType: 'venv' | 'conda' | 'microvenv' | undefined;
23402340
pythonVersion: string | undefined;
23412341
};
23422342
/**

src/client/terminals/codeExecution/codeExecutionManager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export class CodeExecutionManager implements ICodeExecutionManager {
4141
this.disposableRegistry.push(
4242
this.commandManager.registerCommand(cmd as any, async (file: Resource) => {
4343
traceVerbose(`Attempting to run Python file`, file?.fsPath);
44+
const trigger = cmd === Commands.Exec_In_Terminal ? 'command' : 'icon';
45+
const newTerminalPerFile = cmd === Commands.Exec_In_Separate_Terminal;
4446

4547
if (useEnvExtension()) {
4648
try {
@@ -51,6 +53,11 @@ export class CodeExecutionManager implements ICodeExecutionManager {
5153
sendTelemetryEvent(EventName.ENVIRONMENT_CHECK_TRIGGER, undefined, {
5254
trigger: 'run-in-terminal',
5355
});
56+
sendTelemetryEvent(EventName.EXECUTION_CODE, undefined, {
57+
scope: 'file',
58+
trigger,
59+
newTerminalPerFile,
60+
});
5461
return;
5562
}
5663

@@ -66,9 +73,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
6673
trigger: 'run-in-terminal',
6774
});
6875
triggerCreateEnvironmentCheckNonBlocking(CreateEnvironmentCheckKind.File, file);
69-
const trigger = cmd === Commands.Exec_In_Terminal ? 'command' : 'icon';
76+
7077
await this.executeFileInTerminal(file, trigger, {
71-
newTerminalPerFile: cmd === Commands.Exec_In_Separate_Terminal,
78+
newTerminalPerFile,
7279
})
7380
.then(() => {
7481
if (this.shouldTerminalFocusOnStart(file))

0 commit comments

Comments
 (0)