33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import {
7- AuthUtils ,
8- CredentialsStore ,
9- LoginManager ,
10- getTelemetryMetadataForConn ,
11- initializeAuth ,
12- isAnySsoConnection ,
13- } from 'aws-core-vscode/auth'
14- import {
15- AuthState ,
16- AuthUtil ,
17- activate as activateCodeWhisperer ,
18- shutdown as shutdownCodeWhisperer ,
19- } from 'aws-core-vscode/codewhisperer'
6+ import { AuthUtils , CredentialsStore , LoginManager , initializeAuth } from 'aws-core-vscode/auth'
7+ import { activate as activateCodeWhisperer , shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer'
208import { makeEndpointsProvider , registerGenericCommands } from 'aws-core-vscode'
219import { CommonAuthWebview } from 'aws-core-vscode/login'
2210import {
@@ -38,15 +26,13 @@ import {
3826 globals ,
3927 initialize ,
4028 initializeComputeRegion ,
41- isNetworkError ,
4229 messages ,
4330 placeholder ,
4431 setContext ,
4532 setupUninstallHandler ,
4633 maybeShowMinVscodeWarning ,
47- isSageMaker ,
4834} from 'aws-core-vscode/shared'
49- import { ExtStartUpSources , telemetry } from 'aws-core-vscode/telemetry'
35+ import { ExtStartUpSources } from 'aws-core-vscode/telemetry'
5036import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
5137import { join } from 'path'
5238import * as semver from 'semver'
@@ -161,53 +147,6 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
161147 void focusAmazonQPanel . execute ( placeholder , 'firstStartUp' )
162148 } , 1000 )
163149 }
164-
165- await telemetry . auth_userState
166- . run ( async ( ) => {
167- telemetry . record ( { passive : true } )
168-
169- const firstUse = AuthUtils . ExtensionUse . instance . isFirstUse ( )
170- const wasUpdated = AuthUtils . ExtensionUse . instance . wasUpdated ( )
171-
172- if ( firstUse ) {
173- telemetry . record ( { source : ExtStartUpSources . firstStartUp } )
174- } else if ( wasUpdated ) {
175- telemetry . record ( { source : ExtStartUpSources . update } )
176- } else {
177- telemetry . record ( { source : ExtStartUpSources . reload } )
178- }
179-
180- let authState : AuthState = 'disconnected'
181- try {
182- // May call connection validate functions that try to refresh the token.
183- // This could result in network errors.
184- authState = ( await AuthUtil . instance . getChatAuthState ( false ) ) . codewhispererChat
185- } catch ( err ) {
186- if (
187- isNetworkError ( err ) &&
188- AuthUtil . instance . conn &&
189- AuthUtil . instance . auth . getConnectionState ( AuthUtil . instance . conn ) === 'valid'
190- ) {
191- authState = 'connectedWithNetworkError'
192- } else {
193- throw err
194- }
195- }
196- const currConn = AuthUtil . instance . conn
197- if ( currConn !== undefined && ! ( isAnySsoConnection ( currConn ) || isSageMaker ( ) ) ) {
198- getLogger ( ) . error ( `Current Amazon Q connection is not SSO, type is: %s` , currConn ?. type )
199- }
200-
201- telemetry . record ( {
202- authStatus :
203- authState === 'connected' || authState === 'expired' || authState === 'connectedWithNetworkError'
204- ? authState
205- : 'notConnected' ,
206- authEnabledConnections : AuthUtils . getAuthFormIdsFromConnection ( currConn ) . join ( ',' ) ,
207- ...( await getTelemetryMetadataForConn ( currConn ) ) ,
208- } )
209- } )
210- . catch ( ( err ) => getLogger ( ) . error ( 'Error collecting telemetry for auth_userState: %s' , err ) )
211150}
212151
213152export async function deactivateCommon ( ) {
0 commit comments