-
Notifications
You must be signed in to change notification settings - Fork 273
Update telemetry: emit auth scopes in user state #4944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
f157c53
f0d455d
924a2b0
4512625
a4db555
4e1af21
df30b58
2d053c5
13c8cd0
d05315f
744a2d3
098fa1d
e6082fe
214f4d8
e3e4838
5f780a1
1404bb1
82708b7
3ade8d8
0858d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,14 @@ | |
| package software.aws.toolkits.jetbrains.core.gettingstarted | ||
|
|
||
| import com.intellij.openapi.project.Project | ||
| import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService | ||
| import software.amazon.awssdk.services.toolkittelemetry.model.Unit | ||
| import software.aws.toolkits.core.utils.tryOrNull | ||
| import software.aws.toolkits.jetbrains.core.credentials.AwsConnectionManager | ||
| import software.aws.toolkits.jetbrains.core.credentials.LegacyManagedBearerSsoConnection | ||
| import software.aws.toolkits.jetbrains.core.credentials.ManagedBearerSsoConnection | ||
| import software.aws.toolkits.jetbrains.core.credentials.ProfileSsoManagedBearerSsoConnection | ||
| import software.aws.toolkits.jetbrains.core.credentials.ToolkitAuthManager | ||
| import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager | ||
| import software.aws.toolkits.jetbrains.core.credentials.loginSso | ||
| import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeWhispererConnection | ||
|
|
@@ -26,6 +30,7 @@ | |
| import software.aws.toolkits.telemetry.AuthTelemetry | ||
| import software.aws.toolkits.telemetry.FeatureId | ||
| import software.aws.toolkits.telemetry.Result | ||
| import java.time.Instant | ||
|
|
||
| fun requestCredentialsForCodeWhisperer( | ||
| project: Project, | ||
|
|
@@ -229,13 +234,26 @@ | |
| } | ||
|
|
||
| fun emitUserState(project: Project) { | ||
| AuthTelemetry.userState( | ||
| project, | ||
| source = getStartupState().toString(), | ||
| authEnabledConnections = getEnabledConnections(project), | ||
| authStatus = getAuthStatus(project), | ||
| passive = true | ||
| ) | ||
| val explorerConnection = ToolkitConnectionManager.getInstance(project).activeConnection() | ||
|
Check warning on line 237 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt
|
||
| val scopes = when (explorerConnection) { | ||
| is ManagedBearerSsoConnection -> explorerConnection.scopes | ||
| else -> emptyList() | ||
| } | ||
|
|
||
| TelemetryService.getInstance().record(project) { | ||
| datum("auth_userState") { | ||
| createTime(Instant.now()) | ||
| unit(Unit.NONE) | ||
| value(1.0) | ||
|
||
| passive(true) | ||
| metadata("source", getStartupState().toString()) | ||
| metadata("authStatus", getAuthStatus(project).toString()) | ||
| metadata("authEnabledConnections", getEnabledConnections(project)) | ||
| if (getAuthStatus(project).toString() != "notConnected") { | ||
| metadata("authScopes", scopes.joinToString(",")) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const val CODEWHISPERER_AUTH_LEARN_MORE_LINK = "https://docs.aws.amazon.com/codewhisperer/latest/userguide/codewhisperer-auth.html" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, I am just grabbing the connection being used by the explorer. I see that the activeConnection() function is marked as deprecated, but there is no alternative for getting the explorer connection from what I've seen. The getActiveConnectionForFeature function seems to work only for Q, CodeCatalyst, and CodeWhisperer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to look at all the active connections, I think it would be easy enough to use a function like:
aws-toolkit-jetbrains/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/editor/GettingStartedTelemetryUtils.kt
Line 23 in 80abea5
to get the scopes from each active connection. If we are looking at enabled connections in this Telemetry metric, why not the scopes for those enabled connections?