Skip to content

Commit

Permalink
Updated AddConnection telemetry event in LoginBrowser.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
LokeshDogga13 committed Feb 7, 2025
1 parent d148b66 commit e540148
Showing 1 changed file with 45 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ 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 +106,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 +205,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 +226,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 +285,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 +307,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

0 comments on commit e540148

Please sign in to comment.