@@ -43,6 +43,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
43
43
const crcInstaller = new CrcInstall ( ) ;
44
44
extensionApi . configuration . getConfiguration ( ) ;
45
45
const crcVersion = await getCrcVersion ( ) ;
46
+ const telemetryLogger = extensionApi . env . createTelemetryLogger ( ) ;
46
47
47
48
const detectionChecks : extensionApi . ProviderDetectionCheck [ ] = [ ] ;
48
49
let status : extensionApi . ProviderStatus = 'not-installed' ;
@@ -75,13 +76,14 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
75
76
extensionContext . subscriptions . push ( provider ) ;
76
77
77
78
const providerLifecycle : extensionApi . ProviderLifecycle = {
78
- status : ( ) => crcStatus . getProviderStatus ( ) ,
79
-
79
+ status : ( ) => {
80
+ return crcStatus . getProviderStatus ( ) ;
81
+ } ,
80
82
start : context => {
81
- return startCrc ( context . log ) ;
83
+ return startCrc ( context . log , telemetryLogger ) ;
82
84
} ,
83
85
stop : ( ) => {
84
- return stopCrc ( ) ;
86
+ return stopCrc ( telemetryLogger ) ;
85
87
} ,
86
88
} ;
87
89
@@ -92,7 +94,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
92
94
if ( hasSetupFinished ) {
93
95
await needSetup ( ) ;
94
96
connectToCrc ( ) ;
95
- presetChanged ( provider , extensionContext ) ;
97
+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
96
98
}
97
99
} ,
98
100
} ) ,
@@ -101,17 +103,18 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
101
103
extensionContext . subscriptions . push ( provider . registerLifecycle ( providerLifecycle ) ) ;
102
104
103
105
commandManager . setExtContext ( extensionContext ) ;
106
+ commandManager . setTelemetryLogger ( telemetryLogger ) ;
104
107
105
108
registerOpenTerminalCommand ( ) ;
106
109
registerOpenConsoleCommand ( ) ;
107
110
registerLogInCommands ( ) ;
108
111
registerDeleteCommand ( ) ;
109
112
110
- syncPreferences ( extensionContext ) ;
113
+ syncPreferences ( extensionContext , telemetryLogger ) ;
111
114
112
115
if ( ! isNeedSetup ) {
113
116
// initial preset check
114
- presetChanged ( provider , extensionContext ) ;
117
+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
115
118
}
116
119
117
120
if ( crcInstaller . isAbleToInstall ( ) ) {
@@ -125,7 +128,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
125
128
return ;
126
129
}
127
130
await connectToCrc ( ) ;
128
- presetChanged ( provider , extensionContext ) ;
131
+ presetChanged ( provider , extensionContext , telemetryLogger ) ;
129
132
} ) ;
130
133
} ,
131
134
} ) ;
@@ -170,6 +173,7 @@ async function registerOpenShiftLocalCluster(
170
173
name ,
171
174
provider : extensionApi . Provider ,
172
175
extensionContext : extensionApi . ExtensionContext ,
176
+ telemetryLogger : extensionApi . TelemetryLogger ,
173
177
) : Promise < void > {
174
178
const status = ( ) => crcStatus . getConnectionStatus ( ) ;
175
179
const apiURL = 'https://api.crc.testing:6443' ;
@@ -184,10 +188,10 @@ async function registerOpenShiftLocalCluster(
184
188
return deleteCrc ( ) ;
185
189
} ,
186
190
start : ctx => {
187
- return startCrc ( ctx . log ) ;
191
+ return startCrc ( ctx . log , telemetryLogger ) ;
188
192
} ,
189
193
stop : ( ) => {
190
- return stopCrc ( ) ;
194
+ return stopCrc ( telemetryLogger ) ;
191
195
} ,
192
196
} ,
193
197
} ;
@@ -230,6 +234,7 @@ async function connectToCrc(): Promise<void> {
230
234
async function presetChanged (
231
235
provider : extensionApi . Provider ,
232
236
extensionContext : extensionApi . ExtensionContext ,
237
+ telemetryLogger : extensionApi . TelemetryLogger ,
233
238
) : Promise < void > {
234
239
// TODO: handle situation if some cluster/connection was registered already
235
240
@@ -239,8 +244,8 @@ async function presetChanged(
239
244
// podman connection
240
245
registerPodmanConnection ( provider , extensionContext ) ;
241
246
} else if ( preset === 'OpenShift' ) {
242
- registerOpenShiftLocalCluster ( 'OpenShift Local' , provider , extensionContext ) ;
247
+ registerOpenShiftLocalCluster ( 'OpenShift Local' , provider , extensionContext , telemetryLogger ) ;
243
248
} else if ( preset === 'MicroShift' ) {
244
- registerOpenShiftLocalCluster ( 'MicroShift' , provider , extensionContext ) ;
249
+ registerOpenShiftLocalCluster ( 'MicroShift' , provider , extensionContext , telemetryLogger ) ;
245
250
}
246
251
}
0 commit comments