Skip to content

Commit 5c2f07a

Browse files
committed
move telemetry to action from CwsprExplorerActionManager which is supposed to be a pure state machine
1 parent a7f2fe4 commit 5c2f07a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/migration/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
7676
actionState.value[CodeWhispererExploreStateType.SessionConfigurationMessageShown] = isShown
7777
}
7878

79-
fun setAutoSuggestion(project: Project, isAutoEnabled: Boolean) {
79+
fun setAutoSuggestion(isAutoEnabled: Boolean) {
8080
setAutoEnabled(isAutoEnabled)
81-
val autoSuggestionState = if (isAutoEnabled) CodeWhispererConstants.AutoSuggestion.ACTIVATED else CodeWhispererConstants.AutoSuggestion.DEACTIVATED
82-
AwsTelemetry.modifySetting(project, settingId = CodeWhispererConstants.AutoSuggestion.SETTING_ID, settingState = autoSuggestionState)
8381
}
8482

8583
// Adding Auto CodeScan Function

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/actions/Pause.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import com.intellij.icons.AllIcons
77
import com.intellij.openapi.actionSystem.AnActionEvent
88
import com.intellij.openapi.project.DumbAwareAction
99
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
10+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
1011
import software.aws.toolkits.resources.message
12+
import software.aws.toolkits.telemetry.AwsTelemetry
1113

1214
class Pause : DumbAwareAction(
1315
{ message("codewhisperer.explorer.pause_auto") },
@@ -16,6 +18,11 @@ class Pause : DumbAwareAction(
1618
override fun actionPerformed(e: AnActionEvent) {
1719
val project = e.project ?: return
1820

19-
CodeWhispererExplorerActionManager.getInstance().setAutoSuggestion(project, false)
21+
CodeWhispererExplorerActionManager.getInstance().setAutoSuggestion(false)
22+
AwsTelemetry.modifySetting(
23+
project,
24+
settingId = CodeWhispererConstants.AutoSuggestion.SETTING_ID,
25+
settingState = CodeWhispererConstants.AutoSuggestion.DEACTIVATED
26+
)
2027
}
2128
}

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/actions/Resume.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import com.intellij.icons.AllIcons
77
import com.intellij.openapi.actionSystem.AnActionEvent
88
import com.intellij.openapi.project.DumbAwareAction
99
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
10+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
1011
import software.aws.toolkits.resources.message
12+
import software.aws.toolkits.telemetry.AwsTelemetry
1113

1214
class Resume : DumbAwareAction(
1315
{ message("codewhisperer.explorer.resume_auto") },
@@ -16,6 +18,11 @@ class Resume : DumbAwareAction(
1618
override fun actionPerformed(e: AnActionEvent) {
1719
val project = e.project ?: return
1820

19-
CodeWhispererExplorerActionManager.getInstance().setAutoSuggestion(project, true)
21+
CodeWhispererExplorerActionManager.getInstance().setAutoSuggestion(true)
22+
AwsTelemetry.modifySetting(
23+
project,
24+
settingId = CodeWhispererConstants.AutoSuggestion.SETTING_ID,
25+
settingState = CodeWhispererConstants.AutoSuggestion.ACTIVATED
26+
)
2027
}
2128
}

0 commit comments

Comments
 (0)