Skip to content

Updated AuthTelemetry.addConnection telemetry event to Telemetry.auth.addConnection #5338

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

Merged
merged 3 commits into from
Feb 11, 2025
Merged
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 @@ -27,7 +27,9 @@ import software.aws.toolkits.jetbrains.utils.pluginAwareExecuteOnPooledThread
import software.aws.toolkits.resources.AwsCoreBundle
import software.aws.toolkits.telemetry.AuthTelemetry
import software.aws.toolkits.telemetry.FeatureId
import software.aws.toolkits.telemetry.MetricResult
import software.aws.toolkits.telemetry.Result
import software.aws.toolkits.telemetry.Telemetry

fun requestCredentialsForCodeWhisperer(
project: Project,
Expand Down Expand Up @@ -83,16 +85,15 @@ fun requestCredentialsForCodeWhisperer(
)
val isAuthenticationSuccessful = authenticationDialog.showAndGet()
if (isAuthenticationSuccessful) {
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(SourceOfEntry.CODEWHISPERER, isFirstInstance, connectionInitiatedFromExplorer),
featureId = FeatureId.Codewhisperer,
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded,
isReAuth = isReauth
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(SourceOfEntry.CODEWHISPERER, isFirstInstance, connectionInitiatedFromExplorer))
.featureId(FeatureId.Codewhisperer)
.credentialSourceId(authenticationDialog.authType)
.isAggregated(true)
.attempts(authenticationDialog.attempts + 1)
.result(MetricResult.Succeeded)
.isReAuth(isReauth)
}
AuthTelemetry.addedConnections(
project,
source = getSourceOfEntry(SourceOfEntry.CODEWHISPERER, isFirstInstance, connectionInitiatedFromExplorer),
Expand All @@ -104,16 +105,15 @@ fun requestCredentialsForCodeWhisperer(
result = Result.Succeeded
)
} else {
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(SourceOfEntry.CODEWHISPERER, isFirstInstance, connectionInitiatedFromExplorer),
featureId = FeatureId.Codewhisperer,
credentialSourceId = authenticationDialog.authType,
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = isReauth
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(SourceOfEntry.CODEWHISPERER, isFirstInstance, connectionInitiatedFromExplorer))
.featureId(FeatureId.Codewhisperer)
.credentialSourceId(authenticationDialog.authType)
.isAggregated(false)
.attempts(authenticationDialog.attempts + 1)
.result(MetricResult.Cancelled)
.isReAuth(isReauth)
}
}
return isAuthenticationSuccessful
}
Expand Down Expand Up @@ -193,16 +193,15 @@ fun requestCredentialsForQ(

val isAuthenticationSuccessful = authenticationDialog.showAndGet()
if (isAuthenticationSuccessful) {
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(SourceOfEntry.Q, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel),
featureId = FeatureId.AmazonQ,
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded,
isReAuth = isReauth
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(SourceOfEntry.Q, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel))
.featureId(FeatureId.AmazonQ)
.credentialSourceId(authenticationDialog.authType)
.isAggregated(true)
.attempts(authenticationDialog.attempts + 1)
.result(MetricResult.Succeeded)
.isReAuth(isReauth)
}
AuthTelemetry.addedConnections(
project,
source = getSourceOfEntry(SourceOfEntry.Q, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel),
Expand All @@ -214,16 +213,15 @@ fun requestCredentialsForQ(
result = Result.Succeeded
)
} else {
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(SourceOfEntry.Q, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel),
featureId = FeatureId.AmazonQ,
credentialSourceId = authenticationDialog.authType,
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = isReauth
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(SourceOfEntry.Q, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel))
.featureId(FeatureId.AmazonQ)
.credentialSourceId(authenticationDialog.authType)
.isAggregated(false)
.attempts(authenticationDialog.attempts + 1)
.result(MetricResult.Cancelled)
.isReAuth(isReauth)
}
}
return isAuthenticationSuccessful
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ import software.aws.toolkits.jetbrains.utils.runUnderProgressIfNeeded
import software.aws.toolkits.jetbrains.utils.ui.editorNotificationCompoundBorder
import software.aws.toolkits.jetbrains.utils.ui.selected
import software.aws.toolkits.resources.AwsCoreBundle
import software.aws.toolkits.telemetry.AuthTelemetry
import software.aws.toolkits.telemetry.CredentialSourceId
import software.aws.toolkits.telemetry.FeatureId
import software.aws.toolkits.telemetry.Result
import software.aws.toolkits.telemetry.MetricResult
import software.aws.toolkits.telemetry.Telemetry
import java.awt.BorderLayout
import java.util.Optional
import javax.swing.Action
Expand Down Expand Up @@ -279,17 +279,16 @@ class SetupAuthenticationDialog(

val connection = authAndUpdateConfig(project, profile, configFilesFacade, {}, {}) { e ->
Messages.showErrorDialog(project, e.message, title)
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel),
featureId = featureId,
credentialSourceId = CredentialSourceId.IamIdentityCenter,
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "ConnectionUnsuccessful",
isReAuth = false
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel))
.featureId(featureId)
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
.isAggregated(false)
.attempts(++attempts)
.result(MetricResult.Failed)
.reason("ConnectionUnsuccessful")
.isReAuth(false)
}
} ?: return

if (!promptForIdcPermissionSet) {
Expand Down Expand Up @@ -332,17 +331,16 @@ class SetupAuthenticationDialog(

if (existingProfiles.containsKey(profileName)) {
Messages.showErrorDialog(project, AwsCoreBundle.message("gettingstarted.setup.iam.profile.exists", profileName), title)
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer),
featureId = featureId,
credentialSourceId = CredentialSourceId.SharedCredentials,
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "DuplicateProfileName",
isReAuth = false
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer))
.featureId(featureId)
.credentialSourceId(CredentialSourceId.SharedCredentials)
.isAggregated(false)
.attempts(++attempts)
.result(MetricResult.Failed)
.reason("DuplicateProfileName")
.isReAuth(false)
}
return
}

Expand All @@ -359,17 +357,16 @@ class SetupAuthenticationDialog(

if (callerIdentity == null) {
Messages.showErrorDialog(project, AwsCoreBundle.message("gettingstarted.setup.iam.profile.invalid_credentials"), title)
AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer),
featureId = featureId,
credentialSourceId = CredentialSourceId.SharedCredentials,
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "InvalidCredentials",
isReAuth = false
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer))
.featureId(featureId)
.credentialSourceId(CredentialSourceId.SharedCredentials)
.isAggregated(false)
.attempts(++attempts)
.result(MetricResult.Failed)
.reason("InvalidCredentials")
.isReAuth(false)
}
return
}

Expand Down Expand Up @@ -432,18 +429,16 @@ class SetupAuthenticationDialog(

private fun handleConfigFacadeError(e: Exception) {
val (errorMessage, errorType) = messageFromConfigFacadeError(e)

AuthTelemetry.addConnection(
project,
source = getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel),
featureId = featureId,
credentialSourceId = CredentialSourceId.IamIdentityCenter,
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = errorType,
isReAuth = false
)
Telemetry.auth.addConnection.use {
it.source(getSourceOfEntry(sourceOfEntry, isFirstInstance, connectionInitiatedFromExplorer, connectionInitiatedFromQChatPanel))
.featureId(featureId)
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
.isAggregated(false)
.attempts(++attempts)
.result(MetricResult.Failed)
.reason(errorType)
.isReAuth(false)
}

LOG.error(e) { errorMessage }
Messages.showErrorDialog(project, errorMessage, title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ import software.aws.toolkits.jetbrains.core.gettingstarted.editor.SourceOfEntry
import software.aws.toolkits.jetbrains.utils.pluginAwareExecuteOnPooledThread
import software.aws.toolkits.jetbrains.utils.pollFor
import software.aws.toolkits.resources.AwsCoreBundle
import software.aws.toolkits.telemetry.AuthTelemetry
import software.aws.toolkits.telemetry.AuthType
import software.aws.toolkits.telemetry.AwsTelemetry
import software.aws.toolkits.telemetry.CredentialSourceId
import software.aws.toolkits.telemetry.CredentialType
import software.aws.toolkits.telemetry.FeatureId
import software.aws.toolkits.telemetry.MetricResult
import software.aws.toolkits.telemetry.Result
import software.aws.toolkits.telemetry.Telemetry
import java.time.Duration
import java.util.Timer
import java.util.TimerTask
Expand Down Expand Up @@ -104,15 +105,15 @@ abstract class LoginBrowser(
authType = getAuthType(ssoRegion),
source = SourceOfEntry.LOGIN_BROWSER.toString(),
)
AuthTelemetry.addConnection(
result = Result.Failed,
reason = "Browser authentication idle for more than 15min",
credentialSourceId = if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter,
isAggregated = false,
featureId = getFeatureId(scopes),
isReAuth = isReAuth(scopes, startUrl),
source = SourceOfEntry.LOGIN_BROWSER.toString(),
)
Telemetry.auth.addConnection.use {
it.result(MetricResult.Failed)
.reason("Browser authentication idle for more than 15min")
.credentialSourceId(if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter)
.isAggregated(false)
.featureId(getFeatureId(scopes))
.isReAuth(isReAuth(scopes, startUrl))
.source(SourceOfEntry.LOGIN_BROWSER.toString())
}
stopAndClearBrowserOpenTimer()
}
},
Expand Down Expand Up @@ -203,15 +204,15 @@ abstract class LoginBrowser(
authType = getAuthType(SONO_REGION),
source = SourceOfEntry.LOGIN_BROWSER.toString(),
)
AuthTelemetry.addConnection(
result = Result.Failed,
credentialSourceId = CredentialSourceId.AwsId,
reason = e.message,
isReAuth = isReauth,
featureId = featureId,
isAggregated = false,
source = SourceOfEntry.LOGIN_BROWSER.toString()
)
Telemetry.auth.addConnection.use {
it.result(MetricResult.Failed)
.credentialSourceId(CredentialSourceId.AwsId)
.reason(e.message)
.isReAuth(isReauth)
.featureId(featureId)
.isAggregated(false)
.source(SourceOfEntry.LOGIN_BROWSER.toString())
}
}
val onSuccess: () -> Unit = {
stopAndClearBrowserOpenTimer()
Expand All @@ -224,14 +225,14 @@ abstract class LoginBrowser(
authType = getAuthType(SONO_REGION),
source = SourceOfEntry.LOGIN_BROWSER.toString(),
)
AuthTelemetry.addConnection(
result = Result.Succeeded,
credentialSourceId = CredentialSourceId.AwsId,
isReAuth = isReauth,
featureId = featureId,
isAggregated = true,
source = SourceOfEntry.LOGIN_BROWSER.toString()
)
Telemetry.auth.addConnection.use {
it.result(MetricResult.Succeeded)
.credentialSourceId(CredentialSourceId.AwsId)
.isReAuth(isReauth)
.featureId(featureId)
.isAggregated(true)
.source(SourceOfEntry.LOGIN_BROWSER.toString())
}
}

loginWithBackgroundContext {
Expand Down Expand Up @@ -283,15 +284,15 @@ abstract class LoginBrowser(
authType = getAuthType(region.name),
source = SourceOfEntry.LOGIN_BROWSER.toString()
)
AuthTelemetry.addConnection(
result = result,
credentialSourceId = CredentialSourceId.IamIdentityCenter,
reason = message,
isReAuth = isReAuth,
featureId = featureId,
isAggregated = false,
source = SourceOfEntry.LOGIN_BROWSER.toString()
)
Telemetry.auth.addConnection.use {
it.result(result)
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
.reason(message)
.isReAuth(isReAuth)
.featureId(featureId)
.isAggregated(false)
.source(SourceOfEntry.LOGIN_BROWSER.toString())
}
}
val onSuccess: () -> Unit = {
stopAndClearBrowserOpenTimer()
Expand All @@ -305,15 +306,14 @@ abstract class LoginBrowser(
authType = getAuthType(region.name),
source = SourceOfEntry.LOGIN_BROWSER.toString(),
)
AuthTelemetry.addConnection(
project = null,
result = Result.Succeeded,
isReAuth = isReAuth,
credentialSourceId = CredentialSourceId.IamIdentityCenter,
featureId = featureId,
isAggregated = true,
source = SourceOfEntry.LOGIN_BROWSER.toString()
)
Telemetry.auth.addConnection.use {
it.result(MetricResult.Succeeded)
.isReAuth(isReAuth)
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
.featureId(featureId)
.isAggregated(true)
.source(SourceOfEntry.LOGIN_BROWSER.toString())
}
}
return Pair(onError, onSuccess)
}
Expand Down
Loading
Loading