mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] IDEA-350314 Report command finished event with exit code and execution time
The main purpose is to estimate the number of failing commands. GitOrigin-RevId: 507778305e79c9ea85c4b63cd57926bb7a7263a9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b399d63224
commit
2dd5668a1c
@@ -93,7 +93,7 @@ public class ShellTerminalWidget extends JBTerminalWidget {
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER || TerminalShellCommandHandlerHelper.matchedExecutor(e) != null) {
|
||||
TerminalUsageTriggerCollector.triggerCommandExecuted(project, getTypedShellCommand(), false);
|
||||
TerminalUsageTriggerCollector.triggerCommandStarted(project, getTypedShellCommand(), false);
|
||||
if (myShellCommandHandlerHelper.processEnterKeyPressed(e)) {
|
||||
e.consume();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class BlockTerminalController(
|
||||
}
|
||||
}
|
||||
// report event even if it is an empty command, because it will be reported as a separate command type
|
||||
TerminalUsageTriggerCollector.triggerCommandExecuted(project, command, isBlockTerminal = true)
|
||||
TerminalUsageTriggerCollector.triggerCommandStarted(project, command, isBlockTerminal = true)
|
||||
}
|
||||
|
||||
@RequiresEdt(generateAssertion = false)
|
||||
@@ -85,6 +85,7 @@ class BlockTerminalController(
|
||||
|
||||
override fun commandFinished(event: CommandFinishedEvent) {
|
||||
finishCommandBlock(event.exitCode)
|
||||
TerminalUsageTriggerCollector.triggerCommandFinished(project, event.command, event.exitCode, event.duration)
|
||||
}
|
||||
|
||||
private fun finishCommandBlock(exitCode: Int) {
|
||||
|
||||
@@ -14,15 +14,18 @@ import com.intellij.openapi.util.Version
|
||||
import com.intellij.terminal.TerminalShellCommandHandler
|
||||
import com.intellij.util.PathUtil
|
||||
import java.util.*
|
||||
import kotlin.time.Duration
|
||||
|
||||
object TerminalUsageTriggerCollector : CounterUsagesCollector() {
|
||||
override fun getGroup(): EventLogGroup = GROUP
|
||||
|
||||
private val GROUP = EventLogGroup(GROUP_ID, 19)
|
||||
private val GROUP = EventLogGroup(GROUP_ID, 20)
|
||||
|
||||
private val TERMINAL_COMMAND_HANDLER_FIELD = EventFields.Class("terminalCommandHandler")
|
||||
private val RUN_ANYTHING_PROVIDER_FIELD = EventFields.Class("runAnythingProvider")
|
||||
private val BLOCK_TERMINAL_FIELD = EventFields.Boolean("new_terminal")
|
||||
private val EXIT_CODE_FIELD = EventFields.Int("exit_code")
|
||||
private val EXECUTION_TIME_FIELD = EventFields.Long("execution_time", "Time in milliseconds")
|
||||
|
||||
private val sshExecEvent = GROUP.registerEvent("ssh.exec")
|
||||
private val terminalSmartCommandExecutedEvent = GROUP.registerVarargEvent("terminal.smart.command.executed",
|
||||
@@ -36,10 +39,18 @@ object TerminalUsageTriggerCollector : CounterUsagesCollector() {
|
||||
EventFields.String("shell", KNOWN_SHELLS.toList()),
|
||||
BLOCK_TERMINAL_FIELD)
|
||||
|
||||
private val commandExecutedEvent = GROUP.registerEvent("terminal.command.executed",
|
||||
TerminalCommandUsageStatistics.commandExecutableField,
|
||||
TerminalCommandUsageStatistics.subCommandField,
|
||||
BLOCK_TERMINAL_FIELD)
|
||||
private val commandStartedEvent = GROUP.registerEvent("terminal.command.executed",
|
||||
TerminalCommandUsageStatistics.commandExecutableField,
|
||||
TerminalCommandUsageStatistics.subCommandField,
|
||||
BLOCK_TERMINAL_FIELD,
|
||||
"Fired each time when command is started")
|
||||
|
||||
private val commandFinishedEvent = GROUP.registerVarargEvent("terminal.command.finished",
|
||||
"Fired each time when command is finished. New Terminal only.",
|
||||
TerminalCommandUsageStatistics.commandExecutableField,
|
||||
TerminalCommandUsageStatistics.subCommandField,
|
||||
EXIT_CODE_FIELD,
|
||||
EXECUTION_TIME_FIELD)
|
||||
|
||||
private val promotionShownEvent = GROUP.registerEvent("promotion.shown")
|
||||
private val promotionGotItClickedEvent = GROUP.registerEvent("promotion.got.it.clicked")
|
||||
@@ -55,9 +66,18 @@ object TerminalUsageTriggerCollector : CounterUsagesCollector() {
|
||||
fun triggerSshShellStarted(project: Project) = sshExecEvent.log(project)
|
||||
|
||||
@JvmStatic
|
||||
fun triggerCommandExecuted(project: Project, userCommandLine: String, isBlockTerminal: Boolean) {
|
||||
fun triggerCommandStarted(project: Project, userCommandLine: String, isBlockTerminal: Boolean) {
|
||||
val commandData = TerminalCommandUsageStatistics.getLoggableCommandData(userCommandLine)
|
||||
commandExecutedEvent.log(project, commandData?.command, commandData?.subCommand, isBlockTerminal)
|
||||
commandStartedEvent.log(project, commandData?.command, commandData?.subCommand, isBlockTerminal)
|
||||
}
|
||||
|
||||
fun triggerCommandFinished(project: Project, userCommandLine: String, exitCode: Int, executionTime: Duration) {
|
||||
val commandData = TerminalCommandUsageStatistics.getLoggableCommandData(userCommandLine)
|
||||
commandFinishedEvent.log(project,
|
||||
TerminalCommandUsageStatistics.commandExecutableField with commandData?.command,
|
||||
TerminalCommandUsageStatistics.subCommandField with commandData?.subCommand,
|
||||
EXIT_CODE_FIELD with exitCode,
|
||||
EXECUTION_TIME_FIELD with executionTime.inWholeMilliseconds)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
Reference in New Issue
Block a user