@@ -38,16 +38,19 @@ import {
3838 isIamConnection ,
3939 isValidCodeCatalystConnection ,
4040 createSsoProfile ,
41+ hasScopes ,
42+ scopesSsoAccountAccess ,
4143} from './connection'
4244import { Commands , placeholder , RegisteredCommand , vscodeComponent } from '../shared/vscode/commands2'
4345import { Auth } from './auth'
4446import { validateIsNewSsoUrl , validateSsoUrlFormat } from './sso/validation'
4547import { getLogger } from '../shared/logger'
46- import { isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil'
48+ import { isValidAmazonQConnection , isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil'
4749import { authHelpUrl } from '../shared/constants'
4850import { getResourceFromTreeNode } from '../shared/treeview/utils'
4951import { Instance } from '../shared/utilities/typeConstructors'
5052import { openUrl } from '../shared/utilities/vsCodeUtils'
53+ import { AuthFormId } from './ui/vue/authForms/types'
5154import { extensionVersion } from '../shared/vscode/env'
5255import { ExtStartUpSources } from '../shared/telemetry'
5356import { CommonAuthWebview } from '../login/webview/vue/backend'
@@ -684,19 +687,6 @@ export class ExtensionUse {
684687 }
685688}
686689
687- /**
688- * @deprecated
689- * Remove in favor of AuthFormId
690- * Simple readable ID for telemetry reporting
691- */
692- export type AuthSimpleId =
693- | 'sharedCredentials'
694- | 'builderIdCodeWhisperer'
695- | 'builderIdCodeCatalyst'
696- | 'identityCenterCodeWhisperer'
697- | 'identityCenterCodeCatalyst'
698- | 'identityCenterExplorer'
699-
700690type AuthCommands = {
701691 switchConnections : RegisteredCommand < ( auth : Auth | TreeNode | unknown ) => Promise < void > >
702692 help : RegisteredCommand < ( ) => Promise < void > >
@@ -832,3 +822,37 @@ export function initAuthCommands(prefix: string) {
832822 } ) ,
833823 }
834824}
825+
826+ /**
827+ * Returns readable auth Ids for a connection, which are used by telemetry.
828+ */
829+ export function getAuthFormIdsFromConnection ( conn ?: Connection ) : AuthFormId [ ] {
830+ if ( ! conn ) {
831+ return [ ]
832+ }
833+
834+ const authIds : AuthFormId [ ] = [ ]
835+ let connType : 'builderId' | 'identityCenter'
836+
837+ if ( isIamConnection ( conn ) ) {
838+ return [ 'credentials' ]
839+ } else if ( isBuilderIdConnection ( conn ) ) {
840+ connType = 'builderId'
841+ } else if ( isIdcSsoConnection ( conn ) ) {
842+ connType = 'identityCenter'
843+ if ( hasScopes ( conn , scopesSsoAccountAccess ) ) {
844+ authIds . push ( 'identityCenterExplorer' )
845+ }
846+ } else {
847+ return [ 'unknown' ]
848+ }
849+
850+ if ( isValidCodeCatalystConnection ( conn ) ) {
851+ authIds . push ( `${ connType } CodeCatalyst` )
852+ }
853+ if ( isValidAmazonQConnection ( conn ) ) {
854+ authIds . push ( `${ connType } CodeWhisperer` )
855+ }
856+
857+ return authIds
858+ }
0 commit comments