diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 541897f1f4a6..4330aa42c81c 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -204,6 +204,7 @@ export enum Telemetry { NotebookOpenTime = 'DS_INTERNAL.NATIVE.NOTEBOOK_OPEN_TIME', SessionIdleTimeout = 'DATASCIENCE.JUPYTER_IDLE_TIMEOUT', JupyterNotInstalledErrorShown = 'DATASCIENCE.JUPYTER_NOT_INSTALLED_ERROR_SHOWN', + JupyterCommandSearch = 'DATASCIENCE.JUPYTER_COMMAND_SEARCH', UserInstalledJupyter = 'DATASCIENCE.USER_INSTALLED_JUPYTER', UserDidNotInstallJupyter = 'DATASCIENCE.USER_DID_NOT_INSTALL_JUPYTER' } diff --git a/src/client/datascience/interactive-window/interactiveWindow.ts b/src/client/datascience/interactive-window/interactiveWindow.ts index 653c61f4eeb3..98c860b378d4 100644 --- a/src/client/datascience/interactive-window/interactiveWindow.ts +++ b/src/client/datascience/interactive-window/interactiveWindow.ts @@ -17,7 +17,7 @@ import { } from '../../common/application/types'; import { ContextKey } from '../../common/contextKey'; import { IFileSystem } from '../../common/platform/types'; -import { IConfigurationService, IDisposableRegistry } from '../../common/types'; +import { IConfigurationService, IDisposableRegistry, IPersistentStateFactory } from '../../common/types'; import * as localize from '../../common/utils/localize'; import { EXTENSION_ROOT_DIR } from '../../constants'; import { IInterpreterService } from '../../interpreter/contracts'; @@ -48,6 +48,7 @@ import { export class InteractiveWindow extends InteractiveBase implements IInteractiveWindow { private closedEvent: EventEmitter = new EventEmitter(); private waitingForExportCells: boolean = false; + private trackedJupyterStart: boolean = false; constructor( @multiInject(IInteractiveWindowListener) listeners: IInteractiveWindowListener[], @@ -71,7 +72,8 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi @inject(IJupyterVariables) jupyterVariables: IJupyterVariables, @inject(IJupyterDebugger) jupyterDebugger: IJupyterDebugger, @inject(INotebookEditorProvider) editorProvider: INotebookEditorProvider, - @inject(IDataScienceErrorHandler) errorHandler: IDataScienceErrorHandler + @inject(IDataScienceErrorHandler) errorHandler: IDataScienceErrorHandler, + @inject(IPersistentStateFactory) private readonly stateFactory: IPersistentStateFactory ) { super( listeners, @@ -251,7 +253,16 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi protected async closeBecauseOfFailure(_exc: Error): Promise { this.dispose(); } - + protected startServer(): Promise { + // Keep track of users who have used interactive window in a worksapce folder. + // To be used if/when changing workflows related to startup of jupyter. + if (!this.trackedJupyterStart){ + this.trackedJupyterStart = true; + const store = this.stateFactory.createGlobalPersistentState('INTERACTIVE_WINDOW_USED', false); + store.updateValue(true).ignoreErrors(); + } + return super.startServer(); + } @captureTelemetry(Telemetry.ExportNotebook, undefined, false) // tslint:disable-next-line: no-any no-empty private export(cells: ICell[]) { diff --git a/src/client/datascience/jupyter/jupyterCommandFinder.ts b/src/client/datascience/jupyter/jupyterCommandFinder.ts index 5e1f6d77e7c0..2dc9398b52ea 100644 --- a/src/client/datascience/jupyter/jupyterCommandFinder.ts +++ b/src/client/datascience/jupyter/jupyterCommandFinder.ts @@ -209,7 +209,7 @@ export class JupyterCommandFinder { // First we look in the current interpreter const current = await this.interpreterService.getActiveInterpreter(); - + const stopWatch = new StopWatch(); if (isCommandFinderCancelled(command, cancelToken)) { return cancelledResult; } @@ -220,6 +220,8 @@ export class JupyterCommandFinder { // Save our error information. This should propagate out as the error information for the command firstError = found.error; + } else { + this.sendSearchTelemetry(command, 'activeInterpreter', stopWatch.elapsedTime, cancelToken); } // Display a progress message when searching, as this could take a while. @@ -244,6 +246,11 @@ export class JupyterCommandFinder { if (found.status === ModuleExistsStatus.NotFound) { progress.report({ message: localize.DataScience.findJupyterCommandProgressSearchCurrentPath() }); found = await this.findPathCommand(command, cancelToken); + if (found.status !== ModuleExistsStatus.NotFound){ + this.sendSearchTelemetry(command, 'path', stopWatch.elapsedTime, cancelToken); + } + } else { + this.sendSearchTelemetry(command, 'otherInterpreter', stopWatch.elapsedTime, cancelToken); } return found; @@ -256,9 +263,18 @@ export class JupyterCommandFinder { found.error = firstError; } + if (found.status === ModuleExistsStatus.NotFound){ + this.sendSearchTelemetry(command, 'nowhere', stopWatch.elapsedTime, cancelToken); + } + return found; } - + private sendSearchTelemetry(command: JupyterCommands, where: 'activeInterpreter' | 'otherInterpreter' | 'path' | 'nowhere', elapsedTime: number, cancelToken?: CancellationToken){ + if (Cancellation.isCanceled(cancelToken)){ + return; + } + sendTelemetryEvent(Telemetry.JupyterCommandSearch, elapsedTime, {where, command}); + } private async searchOtherInterpretersForCommand( command: JupyterCommands, progress: ProgressNotification, diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 91e0a1e98e67..3acf779fecf8 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -13,7 +13,7 @@ import { AppinsightsKey, EXTENSION_ROOT_DIR, isTestExecution, PVSC_EXTENSION_ID import { traceInfo } from '../common/logger'; import { TerminalShellType } from '../common/terminal/types'; import { StopWatch } from '../common/utils/stopWatch'; -import { NativeKeyboardCommandTelemetry, NativeMouseCommandTelemetry, Telemetry } from '../datascience/constants'; +import { JupyterCommands, NativeKeyboardCommandTelemetry, NativeMouseCommandTelemetry, Telemetry } from '../datascience/constants'; import { DebugConfigurationType } from '../debugger/extension/types'; import { ConsoleType, TriggerType } from '../debugger/types'; import { AutoSelectionRule } from '../interpreter/autoSelection/types'; @@ -1433,6 +1433,7 @@ export interface IEventNamePropertyMapping { [Telemetry.SelectJupyterURI]: never | undefined; [Telemetry.SessionIdleTimeout]: never | undefined; [Telemetry.JupyterNotInstalledErrorShown]: never | undefined; + [Telemetry.JupyterCommandSearch]: { where: 'activeInterpreter' | 'otherInterpreter' | 'path' | 'nowhere'; command: JupyterCommands }; [Telemetry.UserInstalledJupyter]: never | undefined; [Telemetry.UserDidNotInstallJupyter]: never | undefined; [Telemetry.SetJupyterURIToLocal]: never | undefined;