Skip to content
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: 5 additions & 0 deletions src/client/common/terminal/activator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { ITerminalActivationHandler, ITerminalActivator, ITerminalHelper, Termin
import { BaseTerminalActivator } from './base';
import { inTerminalEnvVarExperiment } from '../../experiments/helpers';
import { useEnvExtension } from '../../../envExt/api.internal';
import { EventName } from '../../../telemetry/constants';
import { sendTelemetryEvent } from '../../../telemetry';

@injectable()
export class TerminalActivator implements ITerminalActivator {
Expand Down Expand Up @@ -43,6 +45,9 @@ export class TerminalActivator implements ITerminalActivator {
const activateEnvironment =
settings.terminal.activateEnvironment && !inTerminalEnvVarExperiment(this.experimentService);
if (!activateEnvironment || options?.hideFromUser || useEnvExtension()) {
if (useEnvExtension()) {
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_ACTIVATION_FOR_TERMINAL);
}
return false;
}

Expand Down
17 changes: 17 additions & 0 deletions src/client/pythonEnvironments/creation/createEnvApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,28 @@ export function registerCreateEnvironmentFeatures(
): Promise<CreateEnvironmentResult | undefined> => {
if (useEnvExtension()) {
try {
sendTelemetryEvent(EventName.ENVIRONMENT_CREATING, undefined, {
environmentType: undefined,
pythonVersion: undefined,
});
const result = await executeCommand<PythonEnvironment | undefined>(
'python-envs.createAny',
options,
);
if (result) {
const managerId = result.envId.managerId;
if (managerId === 'ms-python.python:venv') {
sendTelemetryEvent(EventName.ENVIRONMENT_CREATED, undefined, {
environmentType: 'venv',
reason: 'created',
});
}
if (managerId === 'ms-python.python:conda') {
sendTelemetryEvent(EventName.ENVIRONMENT_CREATED, undefined, {
environmentType: 'conda',
reason: 'created',
});
}
return { path: result.environmentPath.path };
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ export interface IEventNamePropertyMapping {
}
*/
[EventName.ENVIRONMENT_CREATING]: {
environmentType: 'venv' | 'conda' | 'microvenv';
environmentType: 'venv' | 'conda' | 'microvenv' | undefined;
pythonVersion: string | undefined;
};
/**
Expand Down
11 changes: 9 additions & 2 deletions src/client/terminals/codeExecution/codeExecutionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class CodeExecutionManager implements ICodeExecutionManager {
this.disposableRegistry.push(
this.commandManager.registerCommand(cmd as any, async (file: Resource) => {
traceVerbose(`Attempting to run Python file`, file?.fsPath);
const trigger = cmd === Commands.Exec_In_Terminal ? 'command' : 'icon';
const newTerminalPerFile = cmd === Commands.Exec_In_Separate_Terminal;

if (useEnvExtension()) {
try {
Expand All @@ -51,6 +53,11 @@ export class CodeExecutionManager implements ICodeExecutionManager {
sendTelemetryEvent(EventName.ENVIRONMENT_CHECK_TRIGGER, undefined, {
trigger: 'run-in-terminal',
});
sendTelemetryEvent(EventName.EXECUTION_CODE, undefined, {
scope: 'file',
trigger,
newTerminalPerFile,
});
return;
}

Expand All @@ -66,9 +73,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
trigger: 'run-in-terminal',
});
triggerCreateEnvironmentCheckNonBlocking(CreateEnvironmentCheckKind.File, file);
const trigger = cmd === Commands.Exec_In_Terminal ? 'command' : 'icon';

await this.executeFileInTerminal(file, trigger, {
newTerminalPerFile: cmd === Commands.Exec_In_Separate_Terminal,
newTerminalPerFile,
})
.then(() => {
if (this.shouldTerminalFocusOnStart(file))
Expand Down