diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageData.kt b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageData.kt
index ff513a77acf2..f0cb1c34af12 100644
--- a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageData.kt
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageData.kt
@@ -96,8 +96,10 @@ class FeatureUsageData {
return if (SystemInfo.isLinux) "Linux" else "Other"
}
- fun addPluginInfo(info: PluginInfo): FeatureUsageData {
- addPluginInfoTo(info, data)
+ fun addPluginInfo(info: PluginInfo?): FeatureUsageData {
+ info?.let {
+ addPluginInfoTo(info, data)
+ }
return this
}
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
index 4332b446562d..04095884a252 100644
--- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml
+++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
@@ -455,8 +455,7 @@
-
-
+
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java
deleted file mode 100644
index efa52d2bde39..000000000000
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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.vcs.statistics;
-
-import com.intellij.internal.statistic.beans.UsageDescriptor;
-import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector;
-import com.intellij.internal.statistic.utils.PluginInfo;
-import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.AbstractVcs;
-import com.intellij.openapi.vcs.ProjectLevelVcsManager;
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class VcsNamesUsagesCollector extends ProjectUsagesCollector {
-
- @Override
- @NotNull
- public String getGroupId() {
- return "vcs.names";
- }
-
- @Override
- @NotNull
- public Set getUsages(@NotNull Project project) {
- return getDescriptors(project);
- }
-
- @NotNull
- public static Set getDescriptors(@NotNull Project project) {
- Set usages = new HashSet<>();
-
- ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
- AbstractVcs[] activeVcss = vcsManager.getAllActiveVcss();
-
- List vcsNames = ContainerUtil.map(activeVcss, vcs -> {
- PluginInfo pluginInfo = PluginInfoDetectorKt.getPluginInfo(vcs.getClass());
- if (pluginInfo.isDevelopedByJetBrains()) return vcs.getName();
- if (pluginInfo.isSafeToReport()) return "third.party." + pluginInfo.getId();
- return "third.party.other";
- });
-
- for (String vcs : vcsNames) {
- usages.add(new UsageDescriptor(vcs, 1));
- }
-
- return usages;
- }
-}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java
deleted file mode 100644
index da9a21954cae..000000000000
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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.vcs.statistics;
-
-import com.intellij.internal.statistic.beans.UsageDescriptor;
-import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
-import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage;
-import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getCountingUsage;
-
-public class VcsStatsUsagesCollector extends ProjectUsagesCollector {
- @Override
- @NotNull
- public String getGroupId() {
- return "vcs.metrics";
- }
-
- @Override
- @NotNull
- public Set getUsages(@NotNull Project project) {
- return getDescriptors(project);
- }
-
- @NotNull
- public static Set getDescriptors(@NotNull Project project) {
- Set usages = new HashSet<>();
-
- ChangeListManagerImpl clm = ChangeListManagerImpl.getInstanceImpl(project);
- ProjectLevelVcsManagerEx vcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
-
- usages.add(getCountingUsage("active.changelists.count", clm.getChangeListsNumber()));
- usages.add(getCountingUsage("unversioned.files.count", clm.getUnversionedFiles().size()));
- usages.add(getCountingUsage("ignored.files.count", clm.getIgnoredFiles().size()));
- usages.add(getCountingUsage("vcs.roots.count", vcsManager.getAllVcsRoots().length));
- usages.add(getBooleanUsage("has.default.vcs.root.mapping", vcsManager.haveDefaultMapping() != null));
-
- return usages;
- }
-}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.kt
new file mode 100644
index 000000000000..0a56dd5a63b2
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.kt
@@ -0,0 +1,82 @@
+// Copyright 2000-2019 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.vcs.statistics
+
+import com.intellij.internal.statistic.beans.MetricEvent
+import com.intellij.internal.statistic.beans.newCounterMetric
+import com.intellij.internal.statistic.beans.newMetric
+import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector
+import com.intellij.internal.statistic.utils.getPluginInfo
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vcs.changes.ChangeListManagerImpl
+import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx
+import com.intellij.util.text.nullize
+import com.intellij.vcsUtil.VcsUtil
+import java.util.*
+
+class VcsUsagesCollector : ProjectUsagesCollector() {
+ override fun getGroupId(): String = "vcs.configuration"
+ override fun getVersion(): Int = 2
+
+ override fun getMetrics(project: Project): Set {
+ val set = HashSet()
+
+ val vcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project)
+ val clm = ChangeListManagerImpl.getInstanceImpl(project)
+ val projectBaseDir = project.basePath?.let { VcsUtil.getVirtualFile(it) }
+
+ for (vcs in vcsManager.allActiveVcss) {
+ val pluginInfo = getPluginInfo(vcs.javaClass)
+
+ val metric = newMetric("active.vcs")
+ metric.data.addPluginInfo(pluginInfo)
+ metric.data.addData("vcs", vcs.name)
+ set.add(metric)
+ }
+
+ for (mapping in vcsManager.directoryMappings) {
+ val vcsName = mapping.vcs.nullize(true)
+ val vcs = vcsManager.findVcsByName(vcsName)
+ val pluginInfo = vcs?.let { getPluginInfo(it.javaClass) }
+
+ val metric = newMetric("mapping")
+ metric.data.addPluginInfo(pluginInfo)
+ metric.data.addData("vcs", vcsName ?: "None")
+ metric.data.addData("is_project_mapping", mapping.isDefaultMapping)
+ if (!mapping.isDefaultMapping) {
+ metric.data.addData("is_base_dir", projectBaseDir != null &&
+ projectBaseDir == VcsUtil.getVirtualFile(mapping.directory))
+ }
+ set.add(metric)
+ }
+
+ val defaultVcs = vcsManager.findVcsByName(vcsManager.haveDefaultMapping())
+ if (defaultVcs != null) {
+ val pluginInfo = getPluginInfo(defaultVcs.javaClass)
+
+ val explicitRoots = vcsManager.directoryMappings
+ .filter { it.vcs == defaultVcs.name }
+ .filter { it.directory.isNotEmpty() }
+ .map { VcsUtil.getVirtualFile(it.directory) }
+ .toSet()
+
+ val projectMappedRoots = vcsManager.allVcsRoots
+ .filter { it.vcs == defaultVcs }
+ .filter { it.path != null && !explicitRoots.contains(it.path) }
+
+ for (vcsRoot in projectMappedRoots) {
+ val metric = newMetric("project.mapped.root")
+ metric.data.addPluginInfo(pluginInfo)
+ metric.data.addData("vcs", defaultVcs.name)
+ metric.data.addData("is_base_dir", vcsRoot.path == projectBaseDir)
+ set.add(metric)
+ }
+ }
+
+ set.add(newCounterMetric("mapped.roots", vcsManager.allVcsRoots.size))
+ set.add(newCounterMetric("changelists", clm.changeListsNumber))
+ set.add(newCounterMetric("unversioned.files", clm.unversionedFiles.size))
+ set.add(newCounterMetric("ignored.files", clm.ignoredFiles.size))
+
+ return set
+ }
+}
diff --git a/plugins/git4idea/resources/META-INF/plugin.xml b/plugins/git4idea/resources/META-INF/plugin.xml
index 11068dfbeb26..9acdd1aa8c9b 100644
--- a/plugins/git4idea/resources/META-INF/plugin.xml
+++ b/plugins/git4idea/resources/META-INF/plugin.xml
@@ -207,7 +207,6 @@
-
diff --git a/plugins/git4idea/src/git4idea/GitProjectMigrationStatisticsCollector.kt b/plugins/git4idea/src/git4idea/GitProjectMigrationStatisticsCollector.kt
deleted file mode 100644
index ce14c8f88c95..000000000000
--- a/plugins/git4idea/src/git4idea/GitProjectMigrationStatisticsCollector.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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 git4idea
-
-import com.intellij.internal.statistic.beans.UsageDescriptor
-import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector
-import com.intellij.internal.statistic.utils.getBooleanUsage
-import com.intellij.internal.statistic.utils.getCountingUsage
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.vcs.ProjectLevelVcsManager
-import com.intellij.openapi.vfs.LocalFileSystem
-import com.intellij.openapi.vfs.VfsUtilCore
-import com.intellij.openapi.vfs.VirtualFile
-
-class GitProjectMigrationStatisticsCollector : ProjectUsagesCollector() {
-
- override fun getUsages(project: Project): Set {
- val usages = hashSetOf()
-
- val gitVcs = GitVcs.getInstance(project)
- val manager = ProjectLevelVcsManager.getInstance(project)
-
- val baseDir = project.baseDir
- val actualGitRoots = manager.getRootsUnderVcs(gitVcs)
- val mappings = manager.directoryMappings.filter { it.vcs != null }
-
- val gitMappings = mappings.filter { it.vcs == gitVcs.name }
- val hasDefaultGitMapping = gitMappings.any { it.isDefaultMapping }
- val explicitlyMappedRoots = gitMappings.mapNotNull { LocalFileSystem.getInstance().findFileByPath(it.directory) }
- val projectMappingRoots = actualGitRoots.toMutableSet() - explicitlyMappedRoots
-
- if (hasDefaultGitMapping) {
- usages.add(getBooleanUsage("base.dir.undefined", baseDir == null))
- usages.add(getBooleanUsage("has.default.git.mapping", hasDefaultGitMapping))
- usages.add(getBooleanUsage("has.other.vcses.mappings", mappings.size != gitMappings.size))
- usages.add(getCountingUsage("git.mappings.count", gitMappings.size))
- usages.add(getCountingUsage("git.detected.roots.count", actualGitRoots.size))
- usages.add(getCountingUsage("project.mapping.roots.count", projectMappingRoots.size))
-
- if (baseDir != null) {
- var prefix: String? = null
- var gitRoot: VirtualFile? = null
-
- if (gitMappings.size == 1 && actualGitRoots.size == 1) {
- prefix = "single.mapping"
- gitRoot = actualGitRoots.single()
- }
- else if (projectMappingRoots.size == 1) {
- prefix = "singe.base.mapping"
- gitRoot = projectMappingRoots.single()
- }
-
- if (gitRoot != null && prefix != null) {
- if (gitRoot == baseDir) {
- usages.add(UsageDescriptor("$prefix.is.base.dir", 1))
- }
- else if (VfsUtilCore.isAncestor(gitRoot, baseDir, false)) {
- usages.add(UsageDescriptor("$prefix.above.base.dir", 1))
- }
- else if (VfsUtilCore.isAncestor(baseDir, gitRoot, false)) {
- usages.add(UsageDescriptor("$prefix.under.base.dir", 1))
- }
- }
- }
- }
-
- return usages
- }
-
- override fun getGroupId(): String {
- return "vcs.git.project.root"
- }
-}