FUS-263 fus: do not report VCS names for unknown third-party plugins

This commit is contained in:
Aleksey Pivovarov
2019-01-31 17:39:53 +03:00
parent a18b4bdbd1
commit fa6f818c33
@@ -3,6 +3,8 @@ 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;
@@ -31,8 +33,15 @@ public class VcsNamesUsagesCollector extends ProjectUsagesCollector {
public static Set<UsageDescriptor> getDescriptors(@NotNull Project project) {
Set<UsageDescriptor> usages = new HashSet<>();
AbstractVcs[] activeVcss = ProjectLevelVcsManager.getInstance(project).getAllActiveVcss();
List<String> vcsNames = ContainerUtil.map(activeVcss, AbstractVcs::getName);
ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
AbstractVcs[] activeVcss = vcsManager.getAllActiveVcss();
List<String> 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));