@@ -7,22 +7,22 @@ import * as vscode from 'vscode'
77import { activateAmazonQCommon , amazonQContextPrefix , deactivateCommon } from './extension'
88import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
99import { 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'
1111import { filetypes , SchemaService } from 'aws-core-vscode/sharedNode'
1212import { updateDevMode } from 'aws-core-vscode/dev'
1313import { CommonAuthViewProvider } from 'aws-core-vscode/login'
1414import { isExtensionActive , VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
1515import { registerSubmitFeedback } from 'aws-core-vscode/feedback'
1616import { 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'
1818import api from './api'
1919import { activate as activateCWChat } from './app/chat/activation'
2020import { activate as activateInlineChat } from './inlineChat/activation'
2121import { beta } from 'aws-core-vscode/dev'
2222import * 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'
2626
2727export async function activate ( context : vscode . ExtensionContext ) {
2828 // 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) {
7373 await setupDevMode ( context )
7474 await beta . activate ( context )
7575
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+ } )
8484
85- // void activateNotifications(context, getAuthState)
85+ void activateNotifications ( context , getAuthState )
8686}
8787
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+ }
104102
105103/**
106104 * Some parts of this do not work in Web mode so we need to set Dev Mode up here.
0 commit comments