@@ -17,7 +17,7 @@ import { Commands } from './shared/vscode/commands2'
17
17
import { documentationUrl , endpointsFileUrl , githubCreateIssueUrl , githubUrl } from './shared/constants'
18
18
import { getIdeProperties , aboutExtension , isCloud9 } from './shared/extensionUtilities'
19
19
import { logAndShowError , logAndShowWebviewError } from './shared/utilities/logAndShowUtils'
20
- import { telemetry } from './shared/telemetry/telemetry'
20
+ import { AuthStatus , telemetry } from './shared/telemetry/telemetry'
21
21
import { openUrl } from './shared/utilities/vsCodeUtils'
22
22
import { activateViewsShared } from './awsexplorer/activationShared'
23
23
@@ -42,6 +42,10 @@ import { UriHandler } from './shared/vscode/uriHandler'
42
42
import { disableAwsSdkWarning } from './shared/awsClientBuilder'
43
43
import { FileResourceFetcher } from './shared/resourcefetcher/fileResourceFetcher'
44
44
import { ResourceFetcher } from './shared/resourcefetcher/resourcefetcher'
45
+ import { ExtStartUpSources , getAuthFormIdsFromConnection } from './shared/telemetry/util'
46
+ import { ExtensionUse } from './auth/utils'
47
+ import { Auth } from './auth'
48
+ import { AuthFormId } from './auth/ui/vue/authForms/types'
45
49
46
50
// In web mode everything must be in a single file, so things like the endpoints file will not be available.
47
51
// The following imports the endpoints file, which causes webpack to bundle it in the final output file
@@ -234,3 +238,38 @@ function wrapWithProgressForCloud9(channel: vscode.OutputChannel): (typeof vscod
234
238
} )
235
239
}
236
240
}
241
+
242
+ export async function emitUserState ( ) {
243
+ await telemetry . auth_userState . run ( async ( ) => {
244
+ telemetry . record ( { passive : true } )
245
+
246
+ const firstUse = ExtensionUse . instance . isFirstUse ( )
247
+ const wasUpdated = ExtensionUse . instance . wasUpdated ( )
248
+
249
+ if ( firstUse ) {
250
+ telemetry . record ( { source : ExtStartUpSources . firstStartUp } )
251
+ } else if ( wasUpdated ) {
252
+ telemetry . record ( { source : ExtStartUpSources . update } )
253
+ } else {
254
+ telemetry . record ( { source : ExtStartUpSources . reload } )
255
+ }
256
+
257
+ let authStatus : AuthStatus = 'notConnected'
258
+ const enabledConnections : Set < AuthFormId > = new Set ( )
259
+ if ( Auth . instance . hasConnections ) {
260
+ authStatus = 'expired'
261
+ ; ( await Auth . instance . listConnections ( ) ) . forEach ( conn => {
262
+ const state = Auth . instance . getConnectionState ( conn )
263
+ if ( state === 'valid' ) {
264
+ authStatus = 'connected'
265
+ }
266
+
267
+ getAuthFormIdsFromConnection ( conn ) . forEach ( id => enabledConnections . add ( id ) )
268
+ } )
269
+ }
270
+ telemetry . record ( {
271
+ authStatus,
272
+ authEnabledConnections : [ ...enabledConnections ] . join ( ',' ) ,
273
+ } )
274
+ } )
275
+ }
0 commit comments