From c48a18367f6eaa6ce5b847e84760f65a06182ff4 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Wed, 13 Mar 2024 16:16:29 +0200 Subject: [PATCH] [terminal] IDEA-348915 Send some usage data with a feedback report Such as most used shell and executed commands number. GitOrigin-RevId: c4de2dd3f8defc98a3d97043ec9c1ec5078466d6 --- .../messages/TerminalBundle.properties | 4 +- .../terminal/exp/TerminalUsageLocalStorage.kt | 3 ++ .../feedback/BlockTerminalFeedbackDialog.kt | 46 +++++++++++++++++-- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/plugins/terminal/resources/messages/TerminalBundle.properties b/plugins/terminal/resources/messages/TerminalBundle.properties index 3b4bd72e427b..b02583398223 100644 --- a/plugins/terminal/resources/messages/TerminalBundle.properties +++ b/plugins/terminal/resources/messages/TerminalBundle.properties @@ -105,4 +105,6 @@ feedback.dialog.rating.interface=Interface/Usability: feedback.dialog.rating.feature.set=Feature set: feedback.dialog.rating.performance=Performance: feedback.dialog.other=Is there anything else you'd like to share? -feedback.dialog.other.placeholder=For example, missing features or vice versa, what you particularly like. \ No newline at end of file +feedback.dialog.other.placeholder=For example, missing features or vice versa, what you particularly like. +feedback.system.info.shell=Most used shell: +feedback.system.info.commands.number=Executed commands number: \ No newline at end of file diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/exp/TerminalUsageLocalStorage.kt b/plugins/terminal/src/org/jetbrains/plugins/terminal/exp/TerminalUsageLocalStorage.kt index 090da3392826..286ef6aac5b5 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/exp/TerminalUsageLocalStorage.kt +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/exp/TerminalUsageLocalStorage.kt @@ -15,6 +15,9 @@ internal class TerminalUsageLocalStorage : PersistentStateComponent(project, forTest) { +internal class BlockTerminalFeedbackDialog(project: Project, forTest: Boolean) : BlockBasedFeedbackDialog(project, forTest) { override val myFeedbackReportId: String = "new_terminal" override val myTitle: String = TerminalBundle.message("feedback.dialog.title") - override val mySystemInfoData: CommonFeedbackSystemData by lazy { - CommonFeedbackSystemData.getCurrentData() + override val mySystemInfoData: BlockTerminalUsageData by lazy { + val usageStorage = TerminalUsageLocalStorage.getInstance() + BlockTerminalUsageData( + mostUsedShell = usageStorage.mostUsedShell, + executedCommandsNumber = usageStorage.executedCommandsNumber, + systemInfo = CommonFeedbackSystemData.getCurrentData() + ) } override val myShowFeedbackSystemInfoDialog: () -> Unit = { - showFeedbackSystemInfoDialog(myProject, mySystemInfoData) + showFeedbackSystemInfoDialog(myProject, mySystemInfoData.systemInfo) { + row(TerminalBundle.message("feedback.system.info.shell")) { + label(mySystemInfoData.mostUsedShell) + } + row(TerminalBundle.message("feedback.system.info.commands.number")) { + label(mySystemInfoData.executedCommandsNumber.toString()) + } + } } override val myBlocks: List = listOf( @@ -40,4 +59,23 @@ internal class BlockTerminalFeedbackDialog(project: Project, forTest: Boolean) : init { init() } +} + +@Serializable +internal data class BlockTerminalUsageData( + @NlsSafe val mostUsedShell: String, + val executedCommandsNumber: Int, + val systemInfo: CommonFeedbackSystemData +) : SystemDataJsonSerializable { + override fun serializeToJson(json: Json): JsonElement { + return json.encodeToJsonElement(this) + } + + override fun toString(): String = buildString { + appendLine(TerminalBundle.message("feedback.system.info.shell")) + appendLine(mostUsedShell) + appendLine(TerminalBundle.message("feedback.system.info.commands.number")) + appendLine(executedCommandsNumber) + append(systemInfo.toString()) + } } \ No newline at end of file