@@ -5,14 +5,15 @@ if ((Reflect as any).metadata === undefined) {
55 // tslint:disable-next-line:no-require-imports no-var-requires
66 require ( 'reflect-metadata' ) ;
77}
8+ import { StopWatch } from './common/stopWatch' ;
9+ // Do not move this linne of code (used to measure extension load times).
10+ const stopWatch = new StopWatch ( ) ;
11+
812import { Container } from 'inversify' ;
9- import {
10- debug , Disposable , ExtensionContext ,
11- extensions , IndentAction , languages , Memento ,
12- OutputChannel , window
13- } from 'vscode' ;
13+ import { debug , Disposable , ExtensionContext , extensions , IndentAction , languages , Memento , OutputChannel , window } from 'vscode' ;
1414import { registerTypes as activationRegisterTypes } from './activation/serviceRegistry' ;
1515import { IExtensionActivationService } from './activation/types' ;
16+ import { IWorkspaceService } from './common/application/types' ;
1617import { PythonSettings } from './common/configSettings' ;
1718import { PYTHON , PYTHON_LANGUAGE , STANDARD_OUTPUT_CHANNEL } from './common/constants' ;
1819import { FeatureDeprecationManager } from './common/featureDeprecationManager' ;
@@ -22,7 +23,6 @@ import { registerTypes as installerRegisterTypes } from './common/installer/serv
2223import { registerTypes as platformRegisterTypes } from './common/platform/serviceRegistry' ;
2324import { registerTypes as processRegisterTypes } from './common/process/serviceRegistry' ;
2425import { registerTypes as commonRegisterTypes } from './common/serviceRegistry' ;
25- import { StopWatch } from './common/stopWatch' ;
2626import { ITerminalHelper } from './common/terminal/types' ;
2727import { GLOBAL_MEMENTO , IConfigurationService , IDisposableRegistry , IExtensionContext , ILogger , IMemento , IOutputChannel , IPersistentStateFactory , WORKSPACE_MEMENTO } from './common/types' ;
2828import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry' ;
@@ -32,7 +32,7 @@ import { registerTypes as debugConfigurationRegisterTypes } from './debugger/con
3232import { IDebugConfigurationProvider } from './debugger/types' ;
3333import { registerTypes as formattersRegisterTypes } from './formatters/serviceRegistry' ;
3434import { IInterpreterSelector } from './interpreter/configuration/types' ;
35- import { ICondaService , IInterpreterService } from './interpreter/contracts' ;
35+ import { ICondaService , IInterpreterService , PythonInterpreter } from './interpreter/contracts' ;
3636import { registerTypes as interpretersRegisterTypes } from './interpreter/serviceRegistry' ;
3737import { ServiceContainer } from './ioc/container' ;
3838import { ServiceManager } from './ioc/serviceManager' ;
@@ -180,16 +180,28 @@ function registerServices(context: ExtensionContext, serviceManager: ServiceMana
180180}
181181
182182async function sendStartupTelemetry ( activatedPromise : Promise < void > , serviceContainer : IServiceContainer ) {
183- const stopWatch = new StopWatch ( ) ;
184183 const logger = serviceContainer . get < ILogger > ( ILogger ) ;
185184 try {
186185 await activatedPromise ;
187186 const terminalHelper = serviceContainer . get < ITerminalHelper > ( ITerminalHelper ) ;
188187 const terminalShellType = terminalHelper . identifyTerminalShell ( terminalHelper . getTerminalShellPath ( ) ) ;
189188 const duration = stopWatch . elapsedTime ;
190189 const condaLocator = serviceContainer . get < ICondaService > ( ICondaService ) ;
191- const condaVersion = await condaLocator . getCondaVersion ( ) . catch ( ( ) => undefined ) ;
192- const props = { condaVersion, terminal : terminalShellType } ;
190+ const interpreterService = serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
191+ const [ condaVersion , interpreter , interpreters ] = await Promise . all ( [
192+ condaLocator . getCondaVersion ( ) . catch ( ( ) => undefined ) ,
193+ interpreterService . getActiveInterpreter ( ) . catch < PythonInterpreter | undefined > ( ( ) => undefined ) ,
194+ interpreterService . getInterpreters ( ) . catch < PythonInterpreter [ ] > ( ( ) => [ ] )
195+ ] ) ;
196+ const workspaceService = serviceContainer . get < IWorkspaceService > ( IWorkspaceService ) ;
197+ const workspaceFolderCount = workspaceService . hasWorkspaceFolders ? workspaceService . workspaceFolders ! . length : 0 ;
198+ const pythonVersion = interpreter ? interpreter . version_info . join ( '.' ) : undefined ;
199+ const interpreterType = interpreter ? interpreter . type : undefined ;
200+ const hasPython3 = interpreters
201+ . filter ( item => item && Array . isArray ( item . version_info ) ? item . version_info [ 0 ] === 3 : false )
202+ . length > 0 ;
203+
204+ const props = { condaVersion, terminal : terminalShellType , pythonVersion, interpreterType, workspaceFolderCount, hasPython3 } ;
193205 sendTelemetryEvent ( EDITOR_LOAD , duration , props ) ;
194206 } catch ( ex ) {
195207 logger . logError ( 'sendStartupTelemetry failed.' , ex ) ;
0 commit comments