From c6cdfa0e26386bd757e6c63bec3840731b372ba9 Mon Sep 17 00:00:00 2001 From: Anastasia Ivanova Date: Thu, 1 Apr 2021 13:46:54 +0200 Subject: [PATCH] IDEA-265654: migrate project.import group to StructuredIdeActivity GitOrigin-RevId: b6773b81ce7de5b2e1201f2f9d47565580de8b9b --- .../ExternalSystemActionsCollector.kt | 2 +- .../statistics/ExternalSystemStatUtil.kt | 19 +++++++++------ .../statistics/ProjectImportCollector.kt | 24 +++++++++++++++++++ .../util/ExternalSystemUtil.java | 5 ++-- .../src/META-INF/PlatformExtensions.xml | 2 +- .../maven/project/MavenProjectsProcessor.java | 10 ++++---- 6 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemActionsCollector.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemActionsCollector.kt index 6383367dcd03..4161b8a15dbb 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemActionsCollector.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemActionsCollector.kt @@ -24,7 +24,7 @@ class ExternalSystemActionsCollector : CounterUsagesCollector() { companion object { private val GROUP = EventLogGroup("build.tools.actions", 4) - private val EXTERNAL_SYSTEM_ID = EventFields.StringValidatedByEnum("system_id", "build_tools") + val EXTERNAL_SYSTEM_ID = EventFields.StringValidatedByEnum("system_id", "build_tools") private val ACTION_EXECUTOR_FIELD = EventFields.StringValidatedByCustomRule("executor", "run_config_executor") private val DELEGATE_ACTION_ID = EventFields.Enum("action_id") diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt index cad61f2675e1..4329b32259b7 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt @@ -1,13 +1,15 @@ // Copyright 2000-2018 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.openapi.externalSystem.statistics -import com.intellij.internal.statistic.IdeActivity +import com.intellij.internal.statistic.StructuredIdeActivity import com.intellij.internal.statistic.eventLog.FeatureUsageData +import com.intellij.internal.statistic.eventLog.events.EventPair import com.intellij.internal.statistic.utils.getPluginInfo import com.intellij.openapi.externalSystem.model.ProjectSystemId +import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsCollector.Companion.EXTERNAL_SYSTEM_ID +import com.intellij.openapi.externalSystem.statistics.ProjectImportCollector.Companion.IMPORT_ACTIVITY import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil import com.intellij.openapi.project.Project -import java.util.function.Consumer fun getAnonymizedSystemId(systemId: ProjectSystemId): String { val manager = ExternalSystemApiUtil.getManager(systemId) ?: return "undefined.system" @@ -23,9 +25,12 @@ fun anonymizeSystemId(systemId: ProjectSystemId?) = systemId?.let { getAnonymizedSystemId(it) } ?: "undefined.system" fun importActivityStarted(project: Project, externalSystemId: ProjectSystemId, - dataConsumer: Consumer): IdeActivity { - return IdeActivity(project, "project.import").startedWithData(Consumer { - addExternalSystemId(it, externalSystemId); - dataConsumer.accept(it) - }) + dataSupplier: (() -> List>)?): StructuredIdeActivity { + return StructuredIdeActivity(project, IMPORT_ACTIVITY).started{ + val data: MutableList> = mutableListOf(EXTERNAL_SYSTEM_ID.with(anonymizeSystemId(externalSystemId))) + if(dataSupplier != null) { + data.addAll(dataSupplier()) + } + data + } } \ No newline at end of file diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt new file mode 100644 index 000000000000..dfcaa0aeed65 --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt @@ -0,0 +1,24 @@ +// Copyright 2000-2021 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.openapi.externalSystem.statistics + +import com.intellij.internal.statistic.IdeActivityGroup +import com.intellij.internal.statistic.eventLog.EventLogGroup +import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector +import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsCollector.Companion.EXTERNAL_SYSTEM_ID + +class ProjectImportCollector : CounterUsagesCollector() { + companion object { + val GROUP = EventLogGroup("project.import", 4) + + @JvmField + val TASK_CLASS = EventFields.Class("task_class") + + @JvmField + val IMPORT_ACTIVITY = IdeActivityGroup(GROUP, startEventAdditionalFields=arrayOf(EXTERNAL_SYSTEM_ID, TASK_CLASS, EventFields.PluginInfo)) + } + + override fun getGroup(): EventLogGroup { + return GROUP + } +} \ No newline at end of file diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java index 79ecd1128800..0e0cdf576c05 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java @@ -25,7 +25,7 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.IdeBundle; import com.intellij.ide.impl.OpenUntrustedProjectChoice; import com.intellij.ide.impl.TrustedProjects; -import com.intellij.internal.statistic.IdeActivity; +import com.intellij.internal.statistic.StructuredIdeActivity; import com.intellij.notification.Notification; import com.intellij.notification.NotificationGroup; import com.intellij.openapi.Disposable; @@ -390,8 +390,7 @@ public final class ExternalSystemUtil { @Override public void execute(@NotNull ProgressIndicator indicator) { String title = ExternalSystemBundle.message("progress.refresh.text", projectName, externalSystemId.getReadableName()); - IdeActivity activity = ExternalSystemStatUtilKt.importActivityStarted(project, externalSystemId, data -> { - }); + StructuredIdeActivity activity = ExternalSystemStatUtilKt.importActivityStarted(project, externalSystemId, null); try { DumbService.getInstance(project).suspendIndexingAndRun(title, () -> executeImpl(indicator)); } diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index c156543e83ed..d55e9cdc99bf 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -704,7 +704,7 @@ - + diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessor.java index 6b4437796240..17cfe3d8497d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessor.java @@ -15,11 +15,12 @@ */ package org.jetbrains.idea.maven.project; -import com.intellij.internal.statistic.IdeActivity; +import com.intellij.internal.statistic.StructuredIdeActivity; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.ControlFlowException; import com.intellij.openapi.externalSystem.statistics.ExternalSystemStatUtilKt; +import com.intellij.openapi.externalSystem.statistics.ProjectImportCollector; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.NlsContexts; @@ -32,6 +33,7 @@ import org.jetbrains.idea.maven.utils.MavenProgressIndicator; import org.jetbrains.idea.maven.utils.MavenTask; import org.jetbrains.idea.maven.utils.MavenUtil; +import java.util.Collections; import java.util.LinkedList; import java.util.Queue; @@ -138,9 +140,9 @@ public class MavenProjectsProcessor { indicator.setFraction(counter / (double)(counter + remained)); MavenProjectsProcessorTask finalTask = task; - IdeActivity activity = ExternalSystemStatUtilKt.importActivityStarted(myProject, MavenUtil.SYSTEM_ID, data -> { - data.addData("task_class", finalTask.getClass().getName()); - }); + StructuredIdeActivity activity = ExternalSystemStatUtilKt.importActivityStarted(myProject, MavenUtil.SYSTEM_ID, () -> + Collections.singletonList(ProjectImportCollector.TASK_CLASS.with(finalTask.getClass())) + ); try { final MavenGeneralSettings mavenGeneralSettings = MavenProjectsManager.getInstance(myProject).getGeneralSettings();