From 528b9bd554a22cf956def588fa924266e6332ccb Mon Sep 17 00:00:00 2001 From: "Svetlana.Zemlyanskaya" Date: Wed, 23 Jan 2019 19:29:44 +0100 Subject: [PATCH] FUS: use the same action id in action and toolbar collectors --- .../persistence/ActionsCollectorImpl.java | 30 +++++++++++++++---- .../persistence/ToolbarClicksCollector.java | 26 +++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java index 62a64f2d3425..aaf748b3649d 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java @@ -11,6 +11,7 @@ import com.intellij.internal.statistic.service.fus.collectors.FUSUsageContext; import com.intellij.internal.statistic.utils.PluginInfo; import com.intellij.internal.statistic.utils.PluginInfoDetectorKt; import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionWithDelegate; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.components.PersistentStateComponent; @@ -75,19 +76,36 @@ public class ActionsCollectorImpl extends ActionsCollector implements Persistent data.addPlace(place); } - final String key = isDevelopedByJB ? toReportedId(action) : DEFAULT_ID; - FUSCounterUsageLogger.logEvent(GROUP, key, data); + FUSCounterUsageLogger.logEvent(GROUP, toReportedId(info, action), data); } @NotNull - private static String toReportedId(@NotNull AnAction action) { - final String actionId = action.isGlobal() ? ActionManager.getInstance().getId(action) : null; - if (StringUtil.isEmpty(actionId)) { - return action.getClass().getName(); + public static String toReportedId(@NotNull PluginInfo info, @NotNull AnAction action) { + String actionId = getActionId(info, action); + if (actionId != null) { + return actionId; + } + + if (action instanceof ActionWithDelegate) { + final Object delegate = ((ActionWithDelegate)action).getDelegate(); + final PluginInfo delegateInfo = PluginInfoDetectorKt.getPluginInfo(delegate.getClass()); + actionId = delegateInfo.isDevelopedByJetBrains() ? delegate.getClass().getName() : DEFAULT_ID; + } + else { + actionId = action.getClass().getName(); } return ConvertUsagesUtil.escapeDescriptorName(actionId); } + @Nullable + private static String getActionId(@NotNull PluginInfo info, @NotNull AnAction action) { + if (!info.isDevelopedByJetBrains()) { + return DEFAULT_ID; + } + + return action.isGlobal() ? ActionManager.getInstance().getId(action) : null; + } + private State myState = new State(); @Nullable diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java index 8c73baa15fc6..292cd35966ef 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java @@ -2,6 +2,7 @@ package com.intellij.internal.statistic.collectors.fus.ui.persistence; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsCollectorImpl; import com.intellij.internal.statistic.eventLog.FeatureUsageDataBuilder; import com.intellij.internal.statistic.eventLog.FeatureUsageGroup; import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; @@ -9,8 +10,6 @@ import com.intellij.internal.statistic.service.fus.collectors.FUSCounterUsageLog import com.intellij.internal.statistic.service.fus.collectors.FUSUsageContext; import com.intellij.internal.statistic.utils.PluginInfo; import com.intellij.internal.statistic.utils.PluginInfoDetectorKt; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionWithDelegate; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.components.*; import com.intellij.util.xmlb.annotations.MapAnnotation; @@ -31,8 +30,7 @@ import java.util.Map; } ) public class ToolbarClicksCollector implements PersistentStateComponent { - private static final FeatureUsageGroup GROUP = new FeatureUsageGroup("toolbar", 1); - private static final String DEFAULT_ID = "third.party.action"; + private static final FeatureUsageGroup GROUP = new FeatureUsageGroup("toolbar", 2); public final static class ClicksState { @Tag("counts") @@ -53,27 +51,11 @@ public class ToolbarClicksCollector implements PersistentStateComponent