FUS: fix logging external system run actions (IDEA-243919)

GitOrigin-RevId: 91cc426ed914880d86828cfae25409919c887ee7
This commit is contained in:
Svetlana.Zemlyanskaya
2020-06-18 19:45:25 +03:00
committed by intellij-monorepo-bot
parent f48f0f2d45
commit 4f37b2da81
@@ -7,9 +7,8 @@ import com.intellij.internal.statistic.collectors.fus.actions.persistence.Action
import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsEventLogGroup.Companion.ACTION_INVOKED_EVENT_ID
import com.intellij.internal.statistic.eventLog.EventFields
import com.intellij.internal.statistic.eventLog.EventLogGroup
import com.intellij.internal.statistic.eventLog.FeatureUsageData
import com.intellij.internal.statistic.eventLog.EventPair
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.externalSystem.model.ProjectSystemId
@@ -24,9 +23,16 @@ class ExternalSystemActionsCollector : CounterUsagesCollector() {
override fun getGroup(): EventLogGroup = GROUP
companion object {
private val GROUP = EventLogGroup("build.tools.actions", 2)
private val GROUP = EventLogGroup("build.tools.actions", 3)
private val EXTERNAL_SYSTEM_ID = EventFields.String("system_id").withCustomEnum("build_tools")
private val ACTION_EXECUTOR_FIELD = EventFields.String("executor").withCustomRule("run_config_executor")
private val DELEGATE_ACTION_ID = EventFields.Enum<ActionId>("action_id")
private val ACTION_INVOKED = ActionsEventLogGroup.registerActionInvokedEvent(GROUP, ACTION_INVOKED_EVENT_ID, EXTERNAL_SYSTEM_ID)
private val DELEGATE_ACTION_INVOKED = GROUP.registerVarargEvent(
ACTION_INVOKED_EVENT_ID, DELEGATE_ACTION_ID, EventFields.ActionPlace,
ActionsEventLogGroup.CONTEXT_MENU, ACTION_EXECUTOR_FIELD, EXTERNAL_SYSTEM_ID
)
@JvmStatic
fun trigger(project: Project?,
@@ -35,16 +41,17 @@ class ExternalSystemActionsCollector : CounterUsagesCollector() {
place: String?,
isFromContextMenu: Boolean,
executor : Executor? = null) {
val data = FeatureUsageData().addProject(project)
val data: MutableList<EventPair<*>> = arrayListOf(DELEGATE_ACTION_ID.with(actionId))
if (place != null) {
data.addPlace(place).addData("context_menu", isFromContextMenu)
data.add(EventFields.ActionPlace.with(place))
data.add(ActionsEventLogGroup.CONTEXT_MENU.with(isFromContextMenu))
}
executor?.let { data.addData("executor", it.id) }
executor?.let { data.add(ACTION_EXECUTOR_FIELD.with(it.id)) }
addExternalSystemId(data, systemId)
data.add(EXTERNAL_SYSTEM_ID.with(anonymizeSystemId(systemId)))
FUCounterUsageLogger.getInstance().logEvent("build.tools.actions", actionId.name, data)
DELEGATE_ACTION_INVOKED.log(project, *data.toTypedArray())
}
@JvmStatic