diff --git a/plugins/git4idea/src/git4idea/GitStatisticsCollector.kt b/plugins/git4idea/src/git4idea/GitStatisticsCollector.kt index 582bcb9f9645..29c30c6f6f8b 100644 --- a/plugins/git4idea/src/git4idea/GitStatisticsCollector.kt +++ b/plugins/git4idea/src/git4idea/GitStatisticsCollector.kt @@ -16,27 +16,20 @@ package git4idea import com.intellij.internal.statistic.AbstractApplicationUsagesCollector -import com.intellij.internal.statistic.UsagesCollector +import com.intellij.internal.statistic.UsageTrigger import com.intellij.internal.statistic.beans.GroupDescriptor import com.intellij.internal.statistic.beans.UsageDescriptor import com.intellij.internal.statistic.getBooleanUsage import com.intellij.internal.statistic.getCountingUsage -import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.project.Project import git4idea.config.GitVcsSettings -import gnu.trove.TObjectIntHashMap fun reportUsage(key: String) { - getUsagesCollector()?.reportUsage(key) -} - -private fun getUsagesCollector() : GitStatisticsCollector? { - return Extensions.getExtensions(UsagesCollector.EP_NAME).find { it is GitStatisticsCollector } as GitStatisticsCollector? + UsageTrigger.trigger(key) } class GitStatisticsCollector : AbstractApplicationUsagesCollector() { private val ID = GroupDescriptor.create("Git") - private val reportedUsages = TObjectIntHashMap() override fun getProjectUsages(project: Project): Set { val repositoryManager = GitUtil.getRepositoryManager(project) @@ -63,16 +56,10 @@ class GitStatisticsCollector : AbstractApplicationUsagesCollector() { usages.add(getCountingUsage("data.remotes.in.project", repository.remotes.size, listOf(0, 1, 2, 5))) } - usages.addAll(reportedUsages.keys().map { UsageDescriptor(it as String, reportedUsages.get(it)) }) - return usages } override fun getGroupId(): GroupDescriptor { return ID } - - internal fun reportUsage(key: String) { - reportedUsages.increment(key) - } } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index 83075d5d840d..2cc27bdaac12 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -89,7 +89,7 @@ class GitBranchPopupActions { if (name != null) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.checkoutNewBranch(name, myRepositories); - reportUsage("usage.branch.create.new"); + reportUsage("git.branch.create.new"); } } } @@ -115,7 +115,7 @@ class GitBranchPopupActions { if (reference != null) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.checkout(reference, true, Collections.singletonList(myRepository), null); - reportUsage("usage.branch.checkout.revision"); + reportUsage("git.branch.checkout.revision"); } } @@ -198,7 +198,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.checkout(myBranchName, false, myRepositories, null); - reportUsage("usage.branch.checkout.local"); + reportUsage("git.branch.checkout.local"); } } @@ -223,7 +223,7 @@ class GitBranchPopupActions { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.checkoutNewBranchStartingFrom(name, myBranchName, myRepositories, null); } - reportUsage("usage.checkout.as.new.branch"); + reportUsage("git.checkout.as.new.branch"); } } @@ -243,7 +243,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.deleteBranch(myBranchName, myRepositories); - reportUsage("usage.branch.delete.local"); + reportUsage("git.branch.delete.local"); } } } @@ -300,7 +300,7 @@ class GitBranchPopupActions { if (name != null) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.checkoutNewBranchStartingFrom(name, myRemoteBranchName, myRepositories, null); - reportUsage("usage.branch.checkout.remote"); + reportUsage("git.branch.checkout.remote"); } } @@ -328,7 +328,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.deleteRemoteBranch(myBranchName, myRepositories); - reportUsage("usage.branch.delete.remote"); + reportUsage("git.branch.delete.remote"); } } } @@ -353,7 +353,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.compare(myBranchName, myRepositories, mySelectedRepository); - reportUsage("usage.branch.compare"); + reportUsage("git.branch.compare"); } } @@ -377,7 +377,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.merge(myBranchName, deleteOnMerge(), myRepositories); - reportUsage("usage.branch.merge"); + reportUsage("git.branch.merge"); } private GitBrancher.DeleteOnMergeOption deleteOnMerge() { @@ -405,7 +405,7 @@ class GitBranchPopupActions { public void actionPerformed(AnActionEvent e) { GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class); brancher.rebase(myRepositories, myBranchName); - reportUsage("usage.branch.rebase"); + reportUsage("git.branch.rebase"); } } }