// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.navigation.actions;

import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsEventLogGroup;
import com.intellij.internal.statistic.eventLog.EventLogGroup;
import com.intellij.internal.statistic.eventLog.events.*;
import com.intellij.internal.statistic.eventLog.fus.FeatureUsageLogger;
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;

import java.util.List;

final class GTDUCollector extends CounterUsagesCollector {

  enum GTDUChoice {
    GTD,
    SU,
    ;
  }

  private static final EnumEventField<GTDUChoice> CHOICE = EventFields.Enum("choice", GTDUChoice.class);
  private static final ClassEventField NAVIGATION_PROVIDER_CLASS = EventFields.Class("navigation_provider_class");
  private static final EventLogGroup GROUP = new EventLogGroup("actions.gtdu", FeatureUsageLogger.getConfigVersion());

  private static final VarargEventId PERFORMED = registerGTDUEvent("performed");
  private static final VarargEventId NAVIGATED = registerGTDUEvent("navigated");

  @NotNull
  private static VarargEventId registerGTDUEvent(String eventId) {
    return GROUP.registerVarargEvent(
      eventId,
      EventFields.InputEvent,
      EventFields.ActionPlace,
      ActionsEventLogGroup.CONTEXT_MENU,
      EventFields.CurrentFile,
      CHOICE,
      NAVIGATION_PROVIDER_CLASS
    );
  }

  static void recordPerformed(@NotNull List<@NotNull EventPair<?>> eventData, @NotNull GTDUChoice choice) {
    PERFORMED.log(ContainerUtil.append(eventData, CHOICE.with(choice)).toArray(new EventPair[0]));
  }

  static void recordNavigated(@NotNull List<@NotNull EventPair<?>> eventData, @NotNull Class<?> navigationProviderClass) {
    NAVIGATED.log(ContainerUtil.append(eventData, NAVIGATION_PROVIDER_CLASS.with(navigationProviderClass)).toArray(new EventPair[0]));
  }

  @Override
  public EventLogGroup getGroup() {
    return GROUP;
  }
}

@@ -409,80 +409,8 @@
 .*;%0A
-import com.intellij.internal.statistic.eventLog.fus.FeatureUsageLogger;%0A
 impo
@@ -1020,45 +1020,10 @@
 u%22, 
-FeatureUsageLogger.getConfigVersion()
+58
 );%0A%0A

Use distinct version number for actions.gtdu group