@@ -43,6 +43,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
4343 const crcInstaller = new CrcInstall ( ) ;
4444 extensionApi . configuration . getConfiguration ( ) ;
4545 const crcVersion = await getCrcVersion ( ) ;
46+ const telemetryLogger = extensionApi . env . createTelemetryLogger ( ) ;
4647
4748 const detectionChecks : extensionApi . ProviderDetectionCheck [ ] = [ ] ;
4849 let status : extensionApi . ProviderStatus = 'not-installed' ;
@@ -75,13 +76,14 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
7576 extensionContext . subscriptions . push ( provider ) ;
7677
7778 const providerLifecycle : extensionApi . ProviderLifecycle = {
78- status : ( ) => crcStatus . getProviderStatus ( ) ,
79-
79+ status : ( ) => {
80+ return crcStatus . getProviderStatus ( ) ;
81+ } ,
8082 start : context => {
81- return startCrc ( context . log ) ;
83+ return startCrc ( context . log , telemetryLogger ) ;
8284 } ,
8385 stop : ( ) => {
84- return stopCrc ( ) ;
86+ return stopCrc ( telemetryLogger ) ;
8587 } ,
8688 } ;
8789
@@ -92,7 +94,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
9294 if ( hasSetupFinished ) {
9395 await needSetup ( ) ;
9496 connectToCrc ( ) ;
95- presetChanged ( provider , extensionContext ) ;
97+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
9698 }
9799 } ,
98100 } ) ,
@@ -101,17 +103,18 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
101103 extensionContext . subscriptions . push ( provider . registerLifecycle ( providerLifecycle ) ) ;
102104
103105 commandManager . setExtContext ( extensionContext ) ;
106+ commandManager . setTelemetryLogger ( telemetryLogger ) ;
104107
105108 registerOpenTerminalCommand ( ) ;
106109 registerOpenConsoleCommand ( ) ;
107110 registerLogInCommands ( ) ;
108111 registerDeleteCommand ( ) ;
109112
110- syncPreferences ( extensionContext ) ;
113+ syncPreferences ( extensionContext , telemetryLogger ) ;
111114
112115 if ( ! isNeedSetup ) {
113116 // initial preset check
114- presetChanged ( provider , extensionContext ) ;
117+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
115118 }
116119
117120 if ( crcInstaller . isAbleToInstall ( ) ) {
@@ -125,7 +128,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
125128 return ;
126129 }
127130 await connectToCrc ( ) ;
128- presetChanged ( provider , extensionContext ) ;
131+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
129132 } ) ;
130133 } ,
131134 } ) ;
@@ -170,6 +173,7 @@ async function registerOpenShiftLocalCluster(
170173 name ,
171174 provider : extensionApi . Provider ,
172175 extensionContext : extensionApi . ExtensionContext ,
176+ telemetryLogger : extensionApi . TelemetryLogger ,
173177) : Promise < void > {
174178 const status = ( ) => crcStatus . getConnectionStatus ( ) ;
175179 const apiURL = 'https://api.crc.testing:6443' ;
@@ -184,10 +188,10 @@ async function registerOpenShiftLocalCluster(
184188 return deleteCrc ( ) ;
185189 } ,
186190 start : ctx => {
187- return startCrc ( ctx . log ) ;
191+ return startCrc ( ctx . log , telemetryLogger ) ;
188192 } ,
189193 stop : ( ) => {
190- return stopCrc ( ) ;
194+ return stopCrc ( telemetryLogger ) ;
191195 } ,
192196 } ,
193197 } ;
@@ -230,6 +234,7 @@ async function connectToCrc(): Promise<void> {
230234async function presetChanged (
231235 provider : extensionApi . Provider ,
232236 extensionContext : extensionApi . ExtensionContext ,
237+ telemetryLogger : extensionApi . TelemetryLogger ,
233238) : Promise < void > {
234239 // TODO: handle situation if some cluster/connection was registered already
235240
@@ -239,8 +244,8 @@ async function presetChanged(
239244 // podman connection
240245 registerPodmanConnection ( provider , extensionContext ) ;
241246 } else if ( preset === 'OpenShift' ) {
242- registerOpenShiftLocalCluster ( 'OpenShift Local' , provider , extensionContext ) ;
247+ registerOpenShiftLocalCluster ( 'OpenShift Local' , provider , extensionContext , telemetryLogger ) ;
243248 } else if ( preset === 'MicroShift' ) {
244- registerOpenShiftLocalCluster ( 'MicroShift' , provider , extensionContext ) ;
249+ registerOpenShiftLocalCluster ( 'MicroShift' , provider , extensionContext , telemetryLogger ) ;
245250 }
246251}
0 commit comments