@@ -38,16 +38,19 @@ import {
38
38
isIamConnection ,
39
39
isValidCodeCatalystConnection ,
40
40
createSsoProfile ,
41
+ hasScopes ,
42
+ scopesSsoAccountAccess ,
41
43
} from './connection'
42
44
import { Commands , placeholder , RegisteredCommand , vscodeComponent } from '../shared/vscode/commands2'
43
45
import { Auth } from './auth'
44
46
import { validateIsNewSsoUrl , validateSsoUrlFormat } from './sso/validation'
45
47
import { getLogger } from '../shared/logger'
46
- import { isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil'
48
+ import { isValidAmazonQConnection , isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil'
47
49
import { authHelpUrl } from '../shared/constants'
48
50
import { getResourceFromTreeNode } from '../shared/treeview/utils'
49
51
import { Instance } from '../shared/utilities/typeConstructors'
50
52
import { openUrl } from '../shared/utilities/vsCodeUtils'
53
+ import { AuthFormId } from './ui/vue/authForms/types'
51
54
import { extensionVersion } from '../shared/vscode/env'
52
55
import { ExtStartUpSources } from '../shared/telemetry'
53
56
import { CommonAuthWebview } from '../login/webview/vue/backend'
@@ -684,19 +687,6 @@ export class ExtensionUse {
684
687
}
685
688
}
686
689
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
-
700
690
type AuthCommands = {
701
691
switchConnections : RegisteredCommand < ( auth : Auth | TreeNode | unknown ) => Promise < void > >
702
692
help : RegisteredCommand < ( ) => Promise < void > >
@@ -832,3 +822,37 @@ export function initAuthCommands(prefix: string) {
832
822
} ) ,
833
823
}
834
824
}
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