@@ -7,22 +7,22 @@ import * as vscode from 'vscode'
7
7
import { activateAmazonQCommon , amazonQContextPrefix , deactivateCommon } from './extension'
8
8
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
9
9
import { activate as activateQGumby } from 'aws-core-vscode/amazonqGumby'
10
- import { ExtContext , globals , CrashMonitoring /* getLogger, isSageMaker,*/ , Experiments } from 'aws-core-vscode/shared'
10
+ import { ExtContext , globals , CrashMonitoring , getLogger , isSageMaker , Experiments } from 'aws-core-vscode/shared'
11
11
import { filetypes , SchemaService } from 'aws-core-vscode/sharedNode'
12
12
import { updateDevMode } from 'aws-core-vscode/dev'
13
13
import { CommonAuthViewProvider } from 'aws-core-vscode/login'
14
14
import { isExtensionActive , VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
15
15
import { registerSubmitFeedback } from 'aws-core-vscode/feedback'
16
16
import { DevOptions } from 'aws-core-vscode/dev'
17
- import { Auth /* , AuthUtils, getTelemetryMetadataForConn, isAnySsoConnection*/ } from 'aws-core-vscode/auth'
17
+ import { Auth , authUtils } from 'aws-core-vscode/auth'
18
18
import api from './api'
19
19
import { activate as activateCWChat } from './app/chat/activation'
20
20
import { activate as activateInlineChat } from './inlineChat/activation'
21
21
import { beta } from 'aws-core-vscode/dev'
22
22
import * as amazonq from 'aws-core-vscode/amazonq'
23
- import { /* activate as activateNotifications,*/ NotificationsController } from 'aws-core-vscode/notifications'
24
- // import { AuthState, AuthUtil } from 'aws-core-vscode/codewhisperer'
25
- // import { telemetry, AuthUserState } from 'aws-core-vscode/telemetry'
23
+ import { activate as activateNotifications , NotificationsController } from 'aws-core-vscode/notifications'
24
+ import { AuthUtil } from 'aws-core-vscode/codewhisperer'
25
+ import { telemetry , AuthUserState , AuthStatus } from 'aws-core-vscode/telemetry'
26
26
27
27
export async function activate ( context : vscode . ExtensionContext ) {
28
28
// IMPORTANT: No other code should be added to this function. Place it in one of the following 2 functions where appropriate.
@@ -73,34 +73,32 @@ async function activateAmazonQNode(context: vscode.ExtensionContext) {
73
73
await setupDevMode ( context )
74
74
await beta . activate ( context )
75
75
76
- // TODO: @opieter Fix telemetry
77
- // Will the web metric look the same?
78
- // telemetry.auth_userState.emit({
79
- // passive: true ,
80
- // result: 'Succeeded' ,
81
- // source: AuthUtils.ExtensionUse. instance.sourceForTelemetry (),
82
- // ... (await getAuthState() ),
83
- // })
76
+ await getAuthState ( )
77
+ telemetry . auth_userState . emit ( {
78
+ passive : true ,
79
+ result : 'Succeeded' ,
80
+ source : authUtils . ExtensionUse . instance . sourceForTelemetry ( ) ,
81
+ authStatus : AuthUtil . instance . getAuthState ( ) ,
82
+ authEnabledConnections : ( await AuthUtil . instance . getAuthFormIds ( ) ) . join ( ',' ) ,
83
+ } )
84
84
85
- // void activateNotifications(context, getAuthState)
85
+ void activateNotifications ( context , getAuthState )
86
86
}
87
87
88
- // async function getAuthState(): Promise<Omit<auth2.AuthState, 'source'>> {
89
- // let authState: AuthState = 'disconnected'
90
- // authState = AuthUtil.instance.getAuthState()
91
-
92
- // if (AuthUtil.instance.isConnected() && !(AuthUtil.instance.isSsoSession() || isSageMaker())) {
93
- // getLogger().error('Current Amazon Q connection is not SSO')
94
- // }
95
-
96
- // return {
97
- // authStatus:
98
- // authState === 'connected' || authState === 'expired'
99
- // ? authState
100
- // : 'notConnected',
101
- // ...(await getTelemetryMetadataForConn(currConn)),
102
- // }
103
- // }
88
+ async function getAuthState ( ) : Promise < Omit < AuthUserState , 'source' > > {
89
+ const state = AuthUtil . instance . getAuthState ( )
90
+
91
+ if ( AuthUtil . instance . isConnected ( ) && ! ( AuthUtil . instance . isSsoSession ( ) || isSageMaker ( ) ) ) {
92
+ getLogger ( ) . error ( 'Current Amazon Q connection is not SSO' )
93
+ }
94
+
95
+ return {
96
+ // @ts -ignore
97
+ authStatus : ( state ?? 'notConnected' ) as AuthStatus ,
98
+ authEnabledConnections : ( await AuthUtil . instance . getAuthFormIds ( ) ) . join ( ',' ) ,
99
+ ...AuthUtil . instance . getTelemetryMetadata ( ) ,
100
+ }
101
+ }
104
102
105
103
/**
106
104
* Some parts of this do not work in Web mode so we need to set Dev Mode up here.
0 commit comments