@@ -20,6 +20,7 @@ import { IFileSystem } from '../../common/platform/types';
2020import { IConfigurationService , IDisposableRegistry , IExperimentsManager } from '../../common/types' ;
2121import { createDeferred , Deferred } from '../../common/utils/async' ;
2222import * as localize from '../../common/utils/localize' ;
23+ import { StopWatch } from '../../common/utils/stopWatch' ;
2324import { IInterpreterService , PythonInterpreter } from '../../interpreter/contracts' ;
2425import { captureTelemetry , sendTelemetryEvent } from '../../telemetry' ;
2526import { generateCellRangesFromDocument } from '../cellFactory' ;
@@ -78,6 +79,7 @@ import { InteractiveWindowMessageListener } from './interactiveWindowMessageList
7879export abstract class InteractiveBase extends WebViewHost < IInteractiveWindowMapping > implements IInteractiveBase {
7980 private unfinishedCells : ICell [ ] = [ ] ;
8081 private restartingKernel : boolean = false ;
82+ private perceivedJupyterStartupTelemetryCaptured : boolean = false ;
8183 private potentiallyUnfinishedStatus : Disposable [ ] = [ ] ;
8284 private addSysInfoPromise : Deferred < boolean > | undefined ;
8385 private _notebook : INotebook | undefined ;
@@ -457,8 +459,8 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
457459 // tslint:disable-next-line: max-func-body-length
458460 protected async submitCode ( code : string , file : string , line : number , id ?: string , _editor ?: TextEditor , debug ?: boolean ) : Promise < boolean > {
459461 traceInfo ( `Submitting code for ${ this . id } ` ) ;
462+ const stopWatch = this . _notebook && ! this . perceivedJupyterStartupTelemetryCaptured ? new StopWatch ( ) : undefined ;
460463 let result = true ;
461-
462464 // Do not execute or render empty code cells
463465 const cellMatcher = new CellMatcher ( this . configService . getSettings ( ) . datascience ) ;
464466 if ( cellMatcher . stripFirstMarker ( code ) . length === 0 ) {
@@ -511,7 +513,16 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
511513 if ( file !== Identifiers . EmptyFileName ) {
512514 await this . _notebook . execute ( `__file__ = '${ file . replace ( / \\ / g, '\\\\' ) } '` , file , line , uuid ( ) , undefined , true ) ;
513515 }
514-
516+ if ( stopWatch && ! this . perceivedJupyterStartupTelemetryCaptured ) {
517+ this . perceivedJupyterStartupTelemetryCaptured = true ;
518+ sendTelemetryEvent ( Telemetry . PerceivedJupyterStartupNotebook , stopWatch ?. elapsedTime ) ;
519+ const disposable = this . _notebook . onSessionStatusChanged ( e => {
520+ if ( e === ServerStatus . Busy ) {
521+ sendTelemetryEvent ( Telemetry . StartExecuteNotebookCellPerceivedCold , stopWatch ?. elapsedTime ) ;
522+ disposable . dispose ( ) ;
523+ }
524+ } ) ;
525+ }
515526 const observable = this . _notebook . executeObservable ( code , file , line , id , false ) ;
516527
517528 // Indicate we executed some code
0 commit comments