44package software.aws.toolkits.jetbrains.services.cwc.controller.chat.telemetry
55
66import com.intellij.openapi.project.Project
7+ import com.intellij.openapi.project.ProjectManager
78import org.jetbrains.annotations.VisibleForTesting
89import software.amazon.awssdk.services.codewhispererruntime.model.ChatInteractWithMessageEvent
910import software.amazon.awssdk.services.codewhispererruntime.model.ChatMessageInteractionType
@@ -14,6 +15,9 @@ import software.aws.toolkits.core.utils.debug
1415import software.aws.toolkits.core.utils.getLogger
1516import software.aws.toolkits.core.utils.info
1617import software.aws.toolkits.core.utils.warn
18+ import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnection
19+ import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
20+ import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
1721import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererClientAdaptor
1822import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomization
1923import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererModelConfigurator
@@ -29,6 +33,7 @@ import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
2933import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings
3034import software.aws.toolkits.jetbrains.utils.notifyError
3135import software.aws.toolkits.resources.message
36+ import software.aws.toolkits.telemetry.AuthTelemetry
3237import software.aws.toolkits.telemetry.CwsprChatCommandType
3338import software.aws.toolkits.telemetry.CwsprChatConversationType
3439import software.aws.toolkits.telemetry.CwsprChatInteractionType
@@ -410,12 +415,23 @@ class TelemetryHelper(private val project: Project, private val sessionStorage:
410415 companion object {
411416 private val logger = getLogger<TelemetryHelper >()
412417
418+
419+ fun getQConnection (): ToolkitConnection ? = ToolkitConnectionManager .getInstance(
420+ ProjectManager .getInstance().openProjects.first()
421+ ).activeConnectionForFeature(QConnection .getInstance())
422+
413423 fun recordOpenChat () {
414424 Telemetry .amazonq.openChat.use { it.passive(true ) }
425+ if (getQConnection() == null ) {
426+ AuthTelemetry .signInPageOpened()
427+ }
415428 }
416429
417430 fun recordCloseChat () {
418431 Telemetry .amazonq.closeChat.use { it.passive(true ) }
432+ if (getQConnection() == null ) {
433+ AuthTelemetry .signInPageClosed()
434+ }
419435 }
420436
421437 fun recordTelemetryChatRunCommand (type : CwsprChatCommandType , name : String? = null, startUrl : String? = null) {
0 commit comments