From d75874110cbd53bae8a2e2b006814ad1fd21331a Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 20 Oct 2023 20:06:13 -0700 Subject: [PATCH] Add telemetry for deactivate prompt (#22274) --- src/client/telemetry/constants.ts | 1 + src/client/telemetry/index.ts | 19 ++++++++++++++++++- .../deactivatePrompt.ts | 10 ++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index de0980ada257..9e29ef808d0d 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -27,6 +27,7 @@ export enum EventName { PYTHON_INTERPRETER_ACTIVATE_ENVIRONMENT_PROMPT = 'PYTHON_INTERPRETER_ACTIVATE_ENVIRONMENT_PROMPT', PYTHON_NOT_INSTALLED_PROMPT = 'PYTHON_NOT_INSTALLED_PROMPT', CONDA_INHERIT_ENV_PROMPT = 'CONDA_INHERIT_ENV_PROMPT', + TERMINAL_DEACTIVATE_PROMPT = 'TERMINAL_DEACTIVATE_PROMPT', REQUIRE_JUPYTER_PROMPT = 'REQUIRE_JUPYTER_PROMPT', ACTIVATED_CONDA_ENV_LAUNCH = 'ACTIVATED_CONDA_ENV_LAUNCH', ENVFILE_VARIABLE_SUBSTITUTION = 'ENVFILE_VARIABLE_SUBSTITUTION', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index cc600d2d59a4..f9ed98eb3764 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1226,13 +1226,30 @@ export interface IEventNamePropertyMapping { selection: 'Allow' | 'Close' | undefined; }; /** - * Telemetry event sent with details when user attempts to run in interactive window when Jupyter is not installed. + * Telemetry event sent with details when user clicks the prompt with the following message: + * + * 'We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we suggest the "terminal.integrated.inheritEnv" setting to be changed to false. Would you like to update this setting?' */ /* __GDPR__ "conda_inherit_env_prompt" : { "selection" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karrtikr" } } */ + [EventName.TERMINAL_DEACTIVATE_PROMPT]: { + /** + * `Yes` When 'Allow' option is selected + * `Close` When 'Close' option is selected + */ + selection: 'Edit script' | "Don't show again" | undefined; + }; + /** + * Telemetry event sent with details when user attempts to run in interactive window when Jupyter is not installed. + */ + /* __GDPR__ + "require_jupyter_prompt" : { + "selection" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karrtikr" } + } + */ [EventName.REQUIRE_JUPYTER_PROMPT]: { /** * `Yes` When 'Yes' option is selected diff --git a/src/client/terminals/envCollectionActivation/deactivatePrompt.ts b/src/client/terminals/envCollectionActivation/deactivatePrompt.ts index c1a7e3d08f49..5871cbac92c8 100644 --- a/src/client/terminals/envCollectionActivation/deactivatePrompt.ts +++ b/src/client/terminals/envCollectionActivation/deactivatePrompt.ts @@ -34,6 +34,8 @@ import { isTestExecution } from '../../common/constants'; import { ProgressService } from '../../common/application/progressService'; import { copyFile, createFile, pathExists } from '../../common/platform/fs-paths'; import { getOSType, OSType } from '../../common/utils/platform'; +import { sendTelemetryEvent } from '../../telemetry'; +import { EventName } from '../../telemetry/constants'; export const terminalDeactivationPromptKey = 'TERMINAL_DEACTIVATION_PROMPT_KEY'; @injectable() @@ -115,12 +117,20 @@ export class TerminalDeactivateLimitationPrompt implements IExtensionSingleActiv // Shell integration is not supported for these shells, in which case this workaround won't work. return; } + const telemetrySelections: ['Edit script', "Don't show again"] = ['Edit script', "Don't show again"]; const { initScript, source, destination } = scriptInfo; const prompts = [Common.editSomething.format(initScript.displayName), Common.doNotShowAgain]; const selection = await this.appShell.showWarningMessage( Interpreters.terminalDeactivatePrompt.format(initScript.displayName), ...prompts, ); + let index = selection ? prompts.indexOf(selection) : 0; + if (selection === prompts[0]) { + index = 0; + } + sendTelemetryEvent(EventName.TERMINAL_DEACTIVATE_PROMPT, undefined, { + selection: selection ? telemetrySelections[index] : undefined, + }); if (!selection) { return; }