Skip to content

Commit e8c5afe

Browse files
committed
telemetry: add domain acccount id telemetry
1 parent 258022e commit e8c5afe

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

packages/core/src/sagemakerunifiedstudio/explorer/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
9595
if (!validateNode(node)) {
9696
return
9797
}
98-
await telemetry.smus_startSpace.run(async (span) => {
98+
await telemetry.smus_openRemoteConnection.run(async (span) => {
9999
span.record({
100100
smusSpaceKey: node.resource.DomainSpaceKey,
101101
smusDomainRegion: node.resource.regionCode,

packages/core/src/sagemakerunifiedstudio/explorer/nodes/sageMakerUnifiedStudioRootNode.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TreeNode } from '../../../shared/treeview/resourceTreeDataProvider'
88
import { getIcon } from '../../../shared/icons'
99
import { getLogger } from '../../../shared/logger/logger'
1010
import { DataZoneClient, DataZoneProject } from '../../shared/client/datazoneClient'
11+
import { DefaultStsClient } from '../../../shared/clients/stsClient'
1112
import { Commands } from '../../../shared/vscode/commands2'
1213
import { telemetry } from '../../../shared/telemetry/telemetry'
1314
import { createQuickPick } from '../../../shared/ui/pickerPrompter'
@@ -237,7 +238,9 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
237238
if (!domainUrl) {
238239
// User cancelled
239240
logger.debug('User cancelled domain URL input')
240-
return
241+
throw new ToolkitError('User cancelled domain URL input', {
242+
cancelled: true,
243+
})
241244
}
242245

243246
// Show a simple status bar message instead of progress dialog
@@ -256,7 +259,7 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
256259
})
257260
}
258261

259-
// Extract domain ID and region for logging
262+
// Extract domain account ID, domain ID, and region for logging
260263
const domainId = connection.domainId
261264
const region = connection.ssoRegion
262265

@@ -265,6 +268,18 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
265268
smusDomainId: domainId,
266269
awsRegion: region,
267270
})
271+
try {
272+
const derCredProvider = await authProvider.getDerCredentialsProvider()
273+
const stsClient = new DefaultStsClient(region, await derCredProvider.getCredentials())
274+
const callerIdentity = await stsClient.getCallerIdentity()
275+
span.record({
276+
smusDomainAccountId: callerIdentity.Account,
277+
})
278+
} catch (err) {
279+
logger.error(
280+
`Failed to resolve AWS account ID via STS Client for domain ${domainId} in region ${region}: ${err}`
281+
)
282+
}
268283

269284
// Show success message
270285
void vscode.window.showInformationMessage(
@@ -334,6 +349,18 @@ export const smusSignOutCommand = Commands.declare('aws.smus.signOut', () => asy
334349
smusDomainId: domainId,
335350
awsRegion: region,
336351
})
352+
try {
353+
const derCredProvider = await authProvider.getDerCredentialsProvider()
354+
const stsClient = new DefaultStsClient(region!, await derCredProvider.getCredentials())
355+
const callerIdentity = await stsClient.getCallerIdentity()
356+
span.record({
357+
smusDomainAccountId: callerIdentity.Account,
358+
})
359+
} catch (err) {
360+
logger.error(
361+
`Failed to resolve AWS account ID via STS Client for domain ${domainId} in region ${region}: ${err}`
362+
)
363+
}
337364

338365
// Delete the connection (this will also invalidate tokens and clear cache)
339366
if (activeConnection) {

packages/core/src/shared/telemetry/vscodeTelemetry.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@
295295
"name": "smusConnectionType",
296296
"type": "string",
297297
"description": "SMUS connection type"
298+
},
299+
{
300+
"name": "smusDomainAccountId",
301+
"type": "string",
302+
"description": "SMUS domain account id"
303+
},
304+
{
305+
"name": "smusProjectAccountId",
306+
"type": "string",
307+
"description": "SMUS project account id"
298308
}
299309
],
300310
"metrics": [
@@ -1359,6 +1369,10 @@
13591369
{
13601370
"type": "smusDomainId",
13611371
"required": false
1372+
},
1373+
{
1374+
"type": "smusDomainAccountId",
1375+
"required": false
13621376
}
13631377
]
13641378
},
@@ -1369,6 +1383,10 @@
13691383
{
13701384
"type": "smusDomainId",
13711385
"required": false
1386+
},
1387+
{
1388+
"type": "smusDomainAccountId",
1389+
"required": false
13721390
}
13731391
]
13741392
},
@@ -1414,7 +1432,7 @@
14141432
"passive": true
14151433
},
14161434
{
1417-
"name": "smus_startSpace",
1435+
"name": "smus_openRemoteConnection",
14181436
"description": "Emitted whenever a user starts a SMUS space",
14191437
"metadata": [
14201438
{

0 commit comments

Comments
 (0)