Skip to content

Commit e9415c3

Browse files
committed
Add domain acccount id telemetry
1 parent 258022e commit e9415c3

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
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: 26 additions & 1 deletion
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'
@@ -256,7 +257,7 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
256257
})
257258
}
258259

259-
// Extract domain ID and region for logging
260+
// Extract domain account ID, domain ID, and region for logging
260261
const domainId = connection.domainId
261262
const region = connection.ssoRegion
262263

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

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

338363
// Delete the connection (this will also invalidate tokens and clear cache)
339364
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)