@@ -15,8 +15,9 @@ import { debounce } from 'lodash'
15
15
import { AuthError , AuthFlowState , userCancelled } from '../types'
16
16
import { ToolkitError } from '../../../../shared/errors'
17
17
import { withTelemetryContext } from '../../../../shared/telemetry/util'
18
+ import { Commands } from '../../../../shared/vscode/commands2'
18
19
import { builderIdStartUrl } from '../../../../auth/sso/constants'
19
- import { RegionProfile } from '../../../../codewhisperer/models/model'
20
+ import { RegionProfile , vsCodeState } from '../../../../codewhisperer/models/model'
20
21
import { randomUUID } from '../../../../shared/crypto'
21
22
import globals from '../../../../shared/extensionGlobals'
22
23
import { telemetry } from '../../../../shared/telemetry/telemetry'
@@ -196,12 +197,40 @@ export class AmazonQLoginWebview extends CommonAuthWebview {
196
197
return [ ]
197
198
}
198
199
199
- override startIamCredentialSetup (
200
+ async startIamCredentialSetup (
200
201
profileName : string ,
201
202
accessKey : string ,
202
203
secretKey : string
203
204
) : Promise < AuthError | undefined > {
204
- throw new Error ( 'Method not implemented.' )
205
+ getLogger ( ) . debug ( `called startIamCredentialSetup()` )
206
+ // Defining separate auth function to emit telemetry before returning from setup
207
+ const runAuth = async ( ) : Promise < AuthError | undefined > => {
208
+ try {
209
+ await AuthUtil . instance . login ( accessKey , secretKey )
210
+ // Add auth telemetry
211
+ this . storeMetricMetadata ( await AuthUtil . instance . getTelemetryMetadata ( ) )
212
+ // Show sign-in message
213
+ void vscode . window . showInformationMessage ( 'AmazonQ: Successfully connected to AWS IAM Credentials' )
214
+ } catch ( e ) {
215
+ getLogger ( ) . error ( 'Failed submitting credentials %O' , e )
216
+ return { id : this . id , text : e as string }
217
+ }
218
+ // Enable code suggestions
219
+ vsCodeState . isFreeTierLimitReached = false
220
+ await Commands . tryExecute ( 'aws.amazonq.enableCodeSuggestions' )
221
+ }
222
+
223
+ const result = await runAuth ( )
224
+
225
+ // Emit telemetry
226
+ this . storeMetricMetadata ( {
227
+ credentialSourceId : 'sharedCredentials' ,
228
+ authEnabledFeatures : 'codewhisperer' ,
229
+ ...this . getResultForMetrics ( result ) ,
230
+ } )
231
+ this . emitAuthMetric ( )
232
+
233
+ return result
205
234
}
206
235
207
236
/** If users are unauthenticated in Q/CW, we should always display the auth screen. */
0 commit comments