Skip to content
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 @@ -88,7 +88,7 @@
AuthFollowUpType.FullAuth,
-> runInEdt {
UiTelemetry.click(project, "amazonq_chatAuthenticate")
requestCredentialsForQ(project, connectionInitiatedFromQChatPanel = true)
requestCredentialsForQ(project, connectionInitiatedFromQChatPanel = true, isReauth = false)

Check warning on line 91 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/auth/AuthController.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/auth/AuthController.kt#L91

Added line #L91 was not covered by tests
}

AuthFollowUpType.ReAuth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
UiTelemetry.click(project, "auth_start_Q")

if (!isQWebviewsAvailable()) {
requestCredentialsForQ(project)
requestCredentialsForQ(project, isReauth = false)

Check warning on line 27 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/explorerActions/SignInToQAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/explorerActions/SignInToQAction.kt#L27

Added line #L27 was not covered by tests
} else {
ToolWindowManager.getInstance(project).getToolWindow(AmazonQToolWindowFactory.WINDOW_ID)?.show()
}
Expand All @@ -42,7 +42,7 @@
reauthConnectionIfNeeded(project, it, isReAuth = true)
} ?: run {
runInEdt {
if (requestCredentialsForQ(project)) {
if (requestCredentialsForQ(project, isReauth = false)) {
if (!openMeetQPage(project)) {
return@runInEdt
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,50 +810,6 @@
"type": "authType"
}
]
},
{
"name": "auth_addConnection",
"description": "Captures the result of adding a new connection in the 'Add New Connection' workflow",
"metadata": [
{
"type": "attempts",
"required": false
},
{
"type": "credentialSourceId"
},
{
"type": "featureId",
"required": false
},
{
"type": "invalidInputFields",
"required": false
},
{
"type": "isAggregated",
"required": false
},
{
"type": "reason",
"required": false
},
{
"type": "result"
},
{
"type": "source",
"required": false
},
{
"type": "credentialStartUrl",
"required": false
},
{
"type": "isReAuth",
"required": false
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
),
isFirstInstance: Boolean = false,
connectionInitiatedFromExplorer: Boolean = false,
isReauth: Boolean = false,

Check warning on line 39 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt#L39

Added line #L39 was not covered by tests
): Boolean {
val authenticationDialog = SetupAuthenticationDialog(
project,
Expand Down Expand Up @@ -87,7 +88,8 @@
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded
result = Result.Succeeded,
isReAuth = isReauth

Check warning on line 92 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt#L91-L92

Added lines #L91 - L92 were not covered by tests
)
AuthTelemetry.addedConnections(
project,
Expand All @@ -108,6 +110,7 @@
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = isReauth

Check warning on line 113 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt#L113

Added line #L113 was not covered by tests
)
}
return isAuthenticationSuccessful
Expand All @@ -123,6 +126,7 @@
isFirstInstance: Boolean = false,
connectionInitiatedFromExplorer: Boolean = false,
connectionInitiatedFromQChatPanel: Boolean = false,
isReauth: Boolean,
): Boolean {
// try to scope upgrade if we have a codewhisperer connection
val codeWhispererConnection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
Expand Down Expand Up @@ -194,7 +198,8 @@
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded
result = Result.Succeeded,
isReAuth = isReauth

Check warning on line 202 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt#L201-L202

Added lines #L201 - L202 were not covered by tests
)
AuthTelemetry.addedConnections(
project,
Expand All @@ -215,6 +220,7 @@
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = isReauth

Check warning on line 223 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedAuthUtils.kt#L223

Added line #L223 was not covered by tests
)
}
return isAuthenticationSuccessful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "ConnectionUnsuccessful"
reason = "ConnectionUnsuccessful",
isReAuth = false
)
} ?: return

Expand Down Expand Up @@ -339,7 +340,8 @@
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "DuplicateProfileName"
reason = "DuplicateProfileName",
isReAuth = false

Check warning on line 344 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt#L343-L344

Added lines #L343 - L344 were not covered by tests
)
return
}
Expand All @@ -365,7 +367,8 @@
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = "InvalidCredentials"
reason = "InvalidCredentials",
isReAuth = false

Check warning on line 371 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt#L370-L371

Added lines #L370 - L371 were not covered by tests
)
return
}
Expand Down Expand Up @@ -438,7 +441,8 @@
isAggregated = false,
attempts = ++attempts,
result = Result.Failed,
reason = errorType
reason = errorType,
isReAuth = false

Check warning on line 445 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/gettingstarted/SetupAuthenticationDialog.kt#L444-L445

Added lines #L444 - L445 were not covered by tests
)

LOG.error(e) { errorMessage }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ enum class SourceOfEntry {
FIRST_STARTUP,
Q,
AMAZONQ_CHAT_PANEL,
LOGIN_BROWSER,
UNKNOWN,
;
override fun toString(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import software.aws.toolkits.jetbrains.core.credentials.sso.PendingAuthorization
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBearerTokenProvider
import software.aws.toolkits.jetbrains.core.credentials.ssoErrorMessageFromException
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
Expand Down Expand Up @@ -87,7 +88,7 @@

private var browserOpenTimer: Timer? = null

private fun startBrowserOpenTimer(startUrl: String, ssoRegion: String) {
private fun startBrowserOpenTimer(startUrl: String, ssoRegion: String, scopes: List<String>) {
browserOpenTimer = Timer()
browserOpenTimer?.schedule(
object : TimerTask() {
Expand All @@ -103,7 +104,11 @@
AuthTelemetry.addConnection(
result = Result.Failed,
reason = "Browser authentication idle for more than 15min",
credentialSourceId = if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter
credentialSourceId = if (startUrl == SONO_URL) CredentialSourceId.AwsId else CredentialSourceId.IamIdentityCenter,
isAggregated = false,
source = SourceOfEntry.LOGIN_BROWSER.toString(),
featureId = getFeatureId(scopes),
isReAuth = isReAuth(scopes, startUrl)

Check warning on line 111 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L108 - L111 were not covered by tests
)
stopAndClearBrowserOpenTimer()
}
Expand All @@ -121,7 +126,7 @@
}

protected val onPendingToken: (InteractiveBearerTokenProvider) -> Unit = { provider ->
startBrowserOpenTimer(provider.startUrl, provider.region)
startBrowserOpenTimer(provider.startUrl, provider.region, provider.scopes)

Check warning on line 129 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added line #L129 was not covered by tests
projectCoroutineScope(project).launch {
val authorization = pollForAuthorization(provider)
if (authorization != null) {
Expand Down Expand Up @@ -180,6 +185,7 @@

open fun loginBuilderId(scopes: List<String>) {
val isReauth = isReAuth(scopes, SONO_URL)
val featureId = getFeatureId(scopes)

Check warning on line 188 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added line #L188 was not covered by tests
val onError: (Exception) -> Unit = { e ->
stopAndClearBrowserOpenTimer()
isUserCancellation(e)
Expand All @@ -196,7 +202,10 @@
result = Result.Failed,
credentialSourceId = CredentialSourceId.AwsId,
reason = e.message,
isReAuth = isReauth
isReAuth = isReauth,
featureId = featureId,
isAggregated = false,
source = SourceOfEntry.LOGIN_BROWSER.toString()

Check warning on line 208 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L205 - L208 were not covered by tests
)
}
val onSuccess: () -> Unit = {
Expand All @@ -212,7 +221,10 @@
AuthTelemetry.addConnection(
result = Result.Succeeded,
credentialSourceId = CredentialSourceId.AwsId,
isReAuth = isReauth
isReAuth = isReauth,
featureId = featureId,
isAggregated = true,
source = SourceOfEntry.LOGIN_BROWSER.toString()

Check warning on line 227 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L224 - L227 were not covered by tests
)
}

Expand All @@ -239,7 +251,7 @@
region: AwsRegion,
): Pair<(Exception) -> Unit, () -> Unit> {
val isReAuth = isReAuth(scopes, url)

val featureId = getFeatureId(scopes)

Check warning on line 254 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added line #L254 was not covered by tests
val onError: (Exception) -> Unit = { e ->
stopAndClearBrowserOpenTimer()
val message = ssoErrorMessageFromException(e)
Expand Down Expand Up @@ -269,6 +281,9 @@
credentialSourceId = CredentialSourceId.IamIdentityCenter,
reason = message,
isReAuth = isReAuth,
featureId = featureId,
isAggregated = false,
source = SourceOfEntry.LOGIN_BROWSER.toString()

Check warning on line 286 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L284 - L286 were not covered by tests
)
}
val onSuccess: () -> Unit = {
Expand All @@ -286,7 +301,10 @@
project = null,
result = Result.Succeeded,
isReAuth = isReAuth,
credentialSourceId = CredentialSourceId.IamIdentityCenter
credentialSourceId = CredentialSourceId.IamIdentityCenter,
featureId = featureId,
isAggregated = true,
source = SourceOfEntry.LOGIN_BROWSER.toString()

Check warning on line 307 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/LoginBrowser.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L304 - L307 were not covered by tests
)
}
return Pair(onError, onSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
package software.aws.toolkits.jetbrains.core.webview

import com.intellij.openapi.util.registry.Registry
import software.aws.toolkits.jetbrains.core.credentials.sono.CODECATALYST_SCOPES
import software.aws.toolkits.jetbrains.core.credentials.sono.Q_SCOPES
import software.aws.toolkits.telemetry.AuthType
import software.aws.toolkits.telemetry.FeatureId

fun getAuthType(region: String = "us-east-1"): AuthType {
val isCommercialRegion = !region.startsWith("us-gov") && !region.startsWith("us-iso") && !region.startsWith("cn")
Expand All @@ -14,3 +17,12 @@
return AuthType.DeviceCode
}
}

fun getFeatureId(scopes: List<String>): FeatureId =
if (scopes.intersect(Q_SCOPES.toSet()).isNotEmpty()) {
FeatureId.Q

Check warning on line 23 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt#L23

Added line #L23 was not covered by tests
} else if (scopes.intersect(CODECATALYST_SCOPES.toSet()).isNotEmpty()) {
FeatureId.Codecatalyst

Check warning on line 25 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt#L25

Added line #L25 was not covered by tests
} else {
FeatureId.AwsExplorer
}

Check warning on line 28 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/webview/WebviewTelemetryUtils.kt#L27-L28

Added lines #L27 - L28 were not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
featureId = FeatureId.Unknown,
credentialSourceId = CredentialSourceId.Unknown,
isAggregated = true,
result = Result.Succeeded
result = Result.Succeeded,
isReAuth = false
)
AuthTelemetry.addedConnections(
project,
Expand All @@ -66,7 +67,8 @@
credentialSourceId = CredentialSourceId.Unknown,
isAggregated = false,
result = Result.Failed,
reason = "Error opening getting started panel"
reason = "Error opening getting started panel",
isReAuth = false

Check warning on line 71 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedOnStartup.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/GettingStartedOnStartup.kt#L70-L71

Added lines #L70 - L71 were not covered by tests
)
AuthTelemetry.addedConnections(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded
result = Result.Succeeded,
isReAuth = false

Check warning on line 93 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt#L92-L93

Added lines #L92 - L93 were not covered by tests
)
AuthTelemetry.addedConnections(
project,
Expand All @@ -110,6 +111,7 @@
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = false

Check warning on line 114 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt#L114

Added line #L114 was not covered by tests
)
}
return isAuthenticationSuccessful
Expand Down Expand Up @@ -157,7 +159,8 @@
credentialSourceId = authenticationDialog.authType,
isAggregated = true,
attempts = authenticationDialog.attempts + 1,
result = Result.Succeeded
result = Result.Succeeded,
isReAuth = false

Check warning on line 163 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt#L162-L163

Added lines #L162 - L163 were not covered by tests
)
AuthTelemetry.addedConnections(
project,
Expand All @@ -178,6 +181,7 @@
isAggregated = false,
attempts = authenticationDialog.attempts + 1,
result = Result.Cancelled,
isReAuth = false

Check warning on line 184 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/ToolkitGettingStartedAuthUtils.kt#L184

Added line #L184 was not covered by tests
)
}
return isAuthSuccessful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@
oldConnectionCount,
initialEnabledConnection,
isFirstInstance,
connectionInitiatedFromExplorer
connectionInitiatedFromExplorer,
isReauth = true

Check warning on line 961 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/editor/GettingStartedPanel.kt

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/gettingstarted/editor/GettingStartedPanel.kt#L960-L961

Added lines #L960 - L961 were not covered by tests
),
panelReauthenticationRequired
)
Expand Down
Loading