Skip to content

Commit e540148

Browse files
committed
Updated AddConnection telemetry event in LoginBrowser.kt
1 parent d148b66 commit e540148

File tree

1 file changed

+45
-44
lines changed
  • plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview

1 file changed

+45
-44
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ import software.aws.toolkits.telemetry.AwsTelemetry
5151
import software.aws.toolkits.telemetry.CredentialSourceId
5252
import software.aws.toolkits.telemetry.CredentialType
5353
import software.aws.toolkits.telemetry.FeatureId
54+
import software.aws.toolkits.telemetry.MetricResult
5455
import software.aws.toolkits.telemetry.Result
56+
import software.aws.toolkits.telemetry.Telemetry
5557
import java.time.Duration
5658
import java.util.Timer
5759
import java.util.TimerTask
@@ -104,15 +106,15 @@ abstract class LoginBrowser(
104106
authType = getAuthType(ssoRegion),
105107
source = SourceOfEntry.LOGIN_BROWSER.toString(),
106108
)
107-
AuthTelemetry.addConnection(
108-
result = Result.Failed,
109-
reason = "Browser authentication idle for more than 15min",
110-
credentialSourceId = if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter,
111-
isAggregated = false,
112-
featureId = getFeatureId(scopes),
113-
isReAuth = isReAuth(scopes, startUrl),
114-
source = SourceOfEntry.LOGIN_BROWSER.toString(),
115-
)
109+
Telemetry.auth.addConnection.use{
110+
it.result(MetricResult.Failed)
111+
.reason("Browser authentication idle for more than 15min")
112+
.credentialSourceId(if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter)
113+
.isAggregated(false)
114+
.featureId(getFeatureId(scopes))
115+
.isReAuth(isReAuth(scopes, startUrl))
116+
.source(SourceOfEntry.LOGIN_BROWSER.toString())
117+
}
116118
stopAndClearBrowserOpenTimer()
117119
}
118120
},
@@ -203,15 +205,15 @@ abstract class LoginBrowser(
203205
authType = getAuthType(SONO_REGION),
204206
source = SourceOfEntry.LOGIN_BROWSER.toString(),
205207
)
206-
AuthTelemetry.addConnection(
207-
result = Result.Failed,
208-
credentialSourceId = CredentialSourceId.AwsId,
209-
reason = e.message,
210-
isReAuth = isReauth,
211-
featureId = featureId,
212-
isAggregated = false,
213-
source = SourceOfEntry.LOGIN_BROWSER.toString()
214-
)
208+
Telemetry.auth.addConnection.use {
209+
it.result(MetricResult.Failed)
210+
.credentialSourceId(CredentialSourceId.AwsId)
211+
.reason(e.message)
212+
.isReAuth(isReauth)
213+
.featureId(featureId)
214+
.isAggregated(false)
215+
.source(SourceOfEntry.LOGIN_BROWSER.toString())
216+
}
215217
}
216218
val onSuccess: () -> Unit = {
217219
stopAndClearBrowserOpenTimer()
@@ -224,14 +226,14 @@ abstract class LoginBrowser(
224226
authType = getAuthType(SONO_REGION),
225227
source = SourceOfEntry.LOGIN_BROWSER.toString(),
226228
)
227-
AuthTelemetry.addConnection(
228-
result = Result.Succeeded,
229-
credentialSourceId = CredentialSourceId.AwsId,
230-
isReAuth = isReauth,
231-
featureId = featureId,
232-
isAggregated = true,
233-
source = SourceOfEntry.LOGIN_BROWSER.toString()
234-
)
229+
Telemetry.auth.addConnection.use {
230+
it.result(MetricResult.Succeeded)
231+
.credentialSourceId(CredentialSourceId.AwsId)
232+
.isReAuth(isReauth)
233+
.featureId(featureId)
234+
.isAggregated(true)
235+
.source(SourceOfEntry.LOGIN_BROWSER.toString())
236+
}
235237
}
236238

237239
loginWithBackgroundContext {
@@ -283,15 +285,15 @@ abstract class LoginBrowser(
283285
authType = getAuthType(region.name),
284286
source = SourceOfEntry.LOGIN_BROWSER.toString()
285287
)
286-
AuthTelemetry.addConnection(
287-
result = result,
288-
credentialSourceId = CredentialSourceId.IamIdentityCenter,
289-
reason = message,
290-
isReAuth = isReAuth,
291-
featureId = featureId,
292-
isAggregated = false,
293-
source = SourceOfEntry.LOGIN_BROWSER.toString()
294-
)
288+
Telemetry.auth.addConnection.use {
289+
it.result(result)
290+
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
291+
.reason(message)
292+
.isReAuth(isReAuth)
293+
.featureId(featureId)
294+
.isAggregated(false)
295+
.source(SourceOfEntry.LOGIN_BROWSER.toString())
296+
}
295297
}
296298
val onSuccess: () -> Unit = {
297299
stopAndClearBrowserOpenTimer()
@@ -305,15 +307,14 @@ abstract class LoginBrowser(
305307
authType = getAuthType(region.name),
306308
source = SourceOfEntry.LOGIN_BROWSER.toString(),
307309
)
308-
AuthTelemetry.addConnection(
309-
project = null,
310-
result = Result.Succeeded,
311-
isReAuth = isReAuth,
312-
credentialSourceId = CredentialSourceId.IamIdentityCenter,
313-
featureId = featureId,
314-
isAggregated = true,
315-
source = SourceOfEntry.LOGIN_BROWSER.toString()
316-
)
310+
Telemetry.auth.addConnection.use {
311+
it.result(MetricResult.Succeeded)
312+
.isReAuth(isReAuth)
313+
.credentialSourceId(CredentialSourceId.IamIdentityCenter)
314+
.featureId(featureId)
315+
.isAggregated(true)
316+
.source(SourceOfEntry.LOGIN_BROWSER.toString())
317+
}
317318
}
318319
return Pair(onError, onSuccess)
319320
}

0 commit comments

Comments
 (0)