Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
if (!validateNode(node)) {
return
}
await telemetry.smus_startSpace.run(async (span) => {
await telemetry.smus_openRemoteConnection.run(async (span) => {
span.record({
smusSpaceKey: node.resource.DomainSpaceKey,
smusDomainRegion: node.resource.regionCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TreeNode } from '../../../shared/treeview/resourceTreeDataProvider'
import { getIcon } from '../../../shared/icons'
import { getLogger } from '../../../shared/logger/logger'
import { DataZoneClient, DataZoneProject } from '../../shared/client/datazoneClient'
import { DefaultStsClient } from '../../../shared/clients/stsClient'
import { Commands } from '../../../shared/vscode/commands2'
import { telemetry } from '../../../shared/telemetry/telemetry'
import { createQuickPick } from '../../../shared/ui/pickerPrompter'
Expand Down Expand Up @@ -237,7 +238,9 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
if (!domainUrl) {
// User cancelled
logger.debug('User cancelled domain URL input')
return
throw new ToolkitError('User cancelled domain URL input', {
cancelled: true,
})
}

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

// Extract domain ID and region for logging
// Extract domain account ID, domain ID, and region for logging
const domainId = connection.domainId
const region = connection.ssoRegion

Expand All @@ -265,6 +268,18 @@ export const smusLoginCommand = Commands.declare('aws.smus.login', () => async (
smusDomainId: domainId,
awsRegion: region,
})
try {
const derCredProvider = await authProvider.getDerCredentialsProvider()
const stsClient = new DefaultStsClient(region, await derCredProvider.getCredentials())
const callerIdentity = await stsClient.getCallerIdentity()
span.record({
smusDomainAccountId: callerIdentity.Account,
})
} catch (err) {
logger.error(
`Failed to resolve AWS account ID via STS Client for domain ${domainId} in region ${region}: ${err}`
)
}

// Show success message
void vscode.window.showInformationMessage(
Expand Down Expand Up @@ -334,6 +349,18 @@ export const smusSignOutCommand = Commands.declare('aws.smus.signOut', () => asy
smusDomainId: domainId,
awsRegion: region,
})
try {
const derCredProvider = await authProvider.getDerCredentialsProvider()
const stsClient = new DefaultStsClient(region!, await derCredProvider.getCredentials())
const callerIdentity = await stsClient.getCallerIdentity()
span.record({
smusDomainAccountId: callerIdentity.Account,
})
} catch (err) {
logger.error(
`Failed to resolve AWS account ID via STS Client for domain ${domainId} in region ${region}: ${err}`
)
}

// Delete the connection (this will also invalidate tokens and clear cache)
if (activeConnection) {
Expand Down
20 changes: 19 additions & 1 deletion packages/core/src/shared/telemetry/vscodeTelemetry.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@
"name": "smusConnectionType",
"type": "string",
"description": "SMUS connection type"
},
{
"name": "smusDomainAccountId",
"type": "string",
"description": "SMUS domain account id"
},
{
"name": "smusProjectAccountId",
"type": "string",
"description": "SMUS project account id"
}
],
"metrics": [
Expand Down Expand Up @@ -1359,6 +1369,10 @@
{
"type": "smusDomainId",
"required": false
},
{
"type": "smusDomainAccountId",
"required": false
}
]
},
Expand All @@ -1369,6 +1383,10 @@
{
"type": "smusDomainId",
"required": false
},
{
"type": "smusDomainAccountId",
"required": false
}
]
},
Expand Down Expand Up @@ -1414,7 +1432,7 @@
"passive": true
},
{
"name": "smus_startSpace",
"name": "smus_openRemoteConnection",
"description": "Emitted whenever a user starts a SMUS space",
"metadata": [
{
Expand Down
Loading