mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[terminal] IDEA-348915 Send some usage data with a feedback report
Such as most used shell and executed commands number. GitOrigin-RevId: c4de2dd3f8defc98a3d97043ec9c1ec5078466d6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b7b5a921a5
commit
c48a18367f
@@ -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.
|
||||
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:
|
||||
@@ -15,6 +15,9 @@ internal class TerminalUsageLocalStorage : PersistentStateComponent<TerminalUsag
|
||||
val executedCommandsNumber: Int
|
||||
get() = state.shellToExecutedCommandsNumber.values.sum()
|
||||
|
||||
val mostUsedShell: String
|
||||
get() = state.shellToExecutedCommandsNumber.keys.maxBy { state.shellToExecutedCommandsNumber[it]!! }
|
||||
|
||||
fun recordCommandExecuted(shellName: String) {
|
||||
state.shellToExecutedCommandsNumber.merge(shellName.lowercase(), 1, Int::plus)
|
||||
}
|
||||
|
||||
+42
-4
@@ -2,23 +2,42 @@
|
||||
package org.jetbrains.plugins.terminal.exp.feedback
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.platform.feedback.dialog.BlockBasedFeedbackDialog
|
||||
import com.intellij.platform.feedback.dialog.CommonFeedbackSystemData
|
||||
import com.intellij.platform.feedback.dialog.SystemDataJsonSerializable
|
||||
import com.intellij.platform.feedback.dialog.showFeedbackSystemInfoDialog
|
||||
import com.intellij.platform.feedback.dialog.uiBlocks.*
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.encodeToJsonElement
|
||||
import org.jetbrains.plugins.terminal.TerminalBundle
|
||||
import org.jetbrains.plugins.terminal.exp.TerminalUsageLocalStorage
|
||||
|
||||
internal class BlockTerminalFeedbackDialog(project: Project, forTest: Boolean) : BlockBasedFeedbackDialog<CommonFeedbackSystemData>(project, forTest) {
|
||||
internal class BlockTerminalFeedbackDialog(project: Project, forTest: Boolean) : BlockBasedFeedbackDialog<BlockTerminalUsageData>(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<FeedbackBlock> = 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())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user