Skip to content

Commit d677876

Browse files
authored
feat(telemetry): add registration info to auth events (#5439)
* feat(telemetry): add registration info to auth events - For easier analysis, auth events (auth_userState, auth_addConnection, aws_refreshCredentials, aws_loginWithBrowser) will now contain start url, region, registration client id, and registration expiration time. * fix package-lock.json * remove redundant telemetry dependency
1 parent cfc6099 commit d677876

23 files changed

+225
-89
lines changed

package-lock.json

Lines changed: 37 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present"
4040
},
4141
"devDependencies": {
42+
"@aws-toolkits/telemetry": "^1.0.239",
4243
"@playwright/browser-chromium": "^1.43.1",
4344
"@types/vscode": "^1.68.0",
4445
"@types/vscode-webview": "^1.57.1",
@@ -68,7 +69,6 @@
6869
"webpack-merge": "^5.10.0"
6970
},
7071
"dependencies": {
71-
"@aws-toolkits/telemetry": "^1.0.232",
7272
"vscode-nls": "^5.2.0",
7373
"vscode-nls-dev": "^4.0.4"
7474
}

packages/amazonq/src/extension.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { AuthUtils, CredentialsStore, LoginManager, SsoConnection, initializeAuth } from 'aws-core-vscode/auth'
6+
import {
7+
AuthUtils,
8+
CredentialsStore,
9+
LoginManager,
10+
getTelemetryMetadataForConn,
11+
initializeAuth,
12+
isAnySsoConnection,
13+
} from 'aws-core-vscode/auth'
714
import {
815
AuthUtil,
916
activate as activateCodeWhisperer,
@@ -149,10 +156,15 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
149156
}
150157

151158
const authState = (await AuthUtil.instance.getChatAuthState()).codewhispererChat
159+
const currConn = AuthUtil.instance.conn
160+
if (currConn !== undefined && !isAnySsoConnection(currConn)) {
161+
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
162+
}
163+
152164
telemetry.record({
153165
authStatus: authState === 'connected' || authState === 'expired' ? authState : 'notConnected',
154-
authEnabledConnections: AuthUtils.getAuthFormIdsFromConnection(AuthUtil.instance.conn).join(','),
155-
authScopes: ((AuthUtil.instance.conn as SsoConnection)?.scopes ?? []).join(','),
166+
authEnabledConnections: AuthUtils.getAuthFormIdsFromConnection(currConn).join(','),
167+
...(await getTelemetryMetadataForConn(currConn)),
156168
})
157169
})
158170
}

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4044,7 +4044,6 @@
40444044
},
40454045
"devDependencies": {
40464046
"@aws-sdk/types": "^3.13.1",
4047-
"@aws-toolkits/telemetry": "^1.0.236",
40484047
"@aws/fully-qualified-names": "^2.1.4",
40494048
"@cspotcode/source-map-support": "^0.8.1",
40504049
"@sinonjs/fake-timers": "^10.0.2",

packages/core/src/auth/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ export class Auth implements AuthService, ConnectionManager {
742742
state: profile.metadata.connectionState,
743743
label: profile.metadata?.label ?? this.getSsoProfileLabel(profile),
744744
getToken: () => this.getToken(id, provider),
745+
getRegistration: () => provider.getClientRegistration(),
745746
}
746747
}
747748

0 commit comments

Comments
 (0)