mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-349862 [change-reminder] remove FUS collectors
Follow-up: ce69225691d9c6a7ef09dcf52c2c0b84f517468c GitOrigin-RevId: 5052ca875f3d8d0967362d1cbb9bf2198b9e60a1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6f1c9caca2
commit
88c8846a96
@@ -30,9 +30,7 @@ Suggested files are listed as <b>People who change the files in the active chang
|
||||
description="A maximum number of changes for which predictions are calculated"/>
|
||||
|
||||
<applicationService serviceImplementation="com.jetbrains.changeReminder.plugin.UserSettings"/>
|
||||
<statistics.counterUsagesCollector implementationClass="com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector"/>
|
||||
<vcs.changes.changesViewModifier implementation="com.jetbrains.changeReminder.changes.ChangeReminderChangesViewModifier"/>
|
||||
<vcsCheckinHandlerFactory implementation="com.jetbrains.changeReminder.stats.commit.ChangeReminderStatsCheckinHandler"/>
|
||||
</extensions>
|
||||
<resource-bundle>messages.ChangeReminderBundle</resource-bundle>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -9,21 +9,13 @@ import com.intellij.openapi.util.Comparing.haveEqualElements
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vcs.changes.*
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesListView
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import com.intellij.util.ui.tree.TreeUtil
|
||||
import com.jetbrains.changeReminder.getGitRootFiles
|
||||
import com.jetbrains.changeReminder.plugin.UserSettings
|
||||
import com.jetbrains.changeReminder.repository.FilesHistoryProvider
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderChangeListChangedEvent
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderNodeExpandedEvent
|
||||
import git4idea.history.GitHistoryTraverser
|
||||
import git4idea.history.GitHistoryTraverserListener
|
||||
import git4idea.history.getTraverser
|
||||
import git4idea.history.subscribeForGitHistoryTraverserCreation
|
||||
import javax.swing.event.TreeExpansionEvent
|
||||
import javax.swing.event.TreeExpansionListener
|
||||
|
||||
@Service(Service.Level.PROJECT)
|
||||
internal class PredictionService(val project: Project) : Disposable {
|
||||
@@ -77,11 +69,6 @@ internal class PredictionService(val project: Project) : Disposable {
|
||||
override fun changeListsChanged() {
|
||||
val changes = ChangeListManager.getInstance(project).defaultChangeList.changes
|
||||
if (!haveEqualElements(changes, lastChanges)) {
|
||||
if (changes.size <= Registry.intValue("vcs.changeReminder.changes.limit")) {
|
||||
val prevFiles = lastChanges.map { ChangesUtil.getFilePath(it) }
|
||||
val curFiles = changes.map { ChangesUtil.getFilePath(it) }
|
||||
ChangeReminderChangeListChangedEvent(prevFiles, predictionData, curFiles).logEvent(project)
|
||||
}
|
||||
calculatePrediction()
|
||||
lastChanges = changes
|
||||
}
|
||||
@@ -99,36 +86,6 @@ internal class PredictionService(val project: Project) : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private val nodeExpandedListener = object : TreeExpansionListener {
|
||||
private var view: ChangesListView? = null
|
||||
override fun treeExpanded(event: TreeExpansionEvent?) {
|
||||
if (event == null) {
|
||||
return
|
||||
}
|
||||
val predictionData = TreeUtil.findObjectInPath(event.path, PredictionData.Prediction::class.java) ?: return
|
||||
ChangeReminderNodeExpandedEvent(predictionData).logEvent(project)
|
||||
}
|
||||
|
||||
override fun treeCollapsed(event: TreeExpansionEvent?) {}
|
||||
|
||||
fun tryToSubscribe() {
|
||||
if (view != null) {
|
||||
return
|
||||
}
|
||||
|
||||
val changeListViewPanel =
|
||||
ChangesViewContentManager.getInstance(project).getActiveComponent(ChangesViewManager.ChangesViewToolWindowPanel::class.java)
|
||||
?: return
|
||||
view = UIUtil.findComponentOfType(changeListViewPanel, ChangesListView::class.java)?.also {
|
||||
it.addTreeExpansionListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun unsubscribe() {
|
||||
view?.removeTreeExpansionListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
if (userSettings.isPluginEnabled) {
|
||||
startService()
|
||||
@@ -153,8 +110,6 @@ internal class PredictionService(val project: Project) : Disposable {
|
||||
}
|
||||
|
||||
private fun calculatePrediction() = synchronized(LOCK) {
|
||||
nodeExpandedListener.tryToSubscribe()
|
||||
|
||||
if (!Disposer.isDisposed(predictionRequestDisposable)) {
|
||||
Disposer.dispose(predictionRequestDisposable)
|
||||
}
|
||||
@@ -199,8 +154,6 @@ internal class PredictionService(val project: Project) : Disposable {
|
||||
private fun shutdownService() = synchronized(LOCK) {
|
||||
Disposer.dispose(predictionRequestDisposable)
|
||||
|
||||
nodeExpandedListener.unsubscribe()
|
||||
|
||||
onTraverserDisposed()
|
||||
|
||||
Disposer.dispose(serviceDisposable)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.events.EventPair
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.jetbrains.changeReminder.predict.PredictionData
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.CHANGELIST_CHANGED
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.CUR_MODIFIED_FILES
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.PREV_MODIFIED_FILES
|
||||
|
||||
internal class ChangeReminderChangeListChangedEvent(
|
||||
private val prevModifiedFiles: Collection<FilePath>,
|
||||
private val displayedPredictionData: PredictionData,
|
||||
private val curModifiedFiles: Collection<FilePath>
|
||||
) : ChangeReminderUserEvent {
|
||||
|
||||
override fun logEvent(project: Project) {
|
||||
val data = ArrayList<EventPair<*>>()
|
||||
data.add(PREV_MODIFIED_FILES.with(prevModifiedFiles.anonymizeFilePathCollection()))
|
||||
data.addAll(getPredictionData(displayedPredictionData))
|
||||
data.add(CUR_MODIFIED_FILES.with(curModifiedFiles.anonymizeFilePathCollection()))
|
||||
CHANGELIST_CHANGED.log(project, data)
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.events.EventPair
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.jetbrains.changeReminder.predict.PredictionData
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.CHANGES_COMMITTED
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.COMMITTED_FILES
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.CUR_MODIFIED_FILES
|
||||
|
||||
internal class ChangeReminderChangesCommittedEvent(
|
||||
private val curModifiedFiles: Collection<FilePath>,
|
||||
private val committedFiles: Collection<FilePath>,
|
||||
private val displayedPredictionData: PredictionData
|
||||
) : ChangeReminderUserEvent {
|
||||
|
||||
override fun logEvent(project: Project) {
|
||||
val data = ArrayList<EventPair<*>>()
|
||||
data.add(CUR_MODIFIED_FILES.with(curModifiedFiles.anonymizeFilePathCollection()))
|
||||
data.add(COMMITTED_FILES.with(committedFiles.anonymizeFilePathCollection()))
|
||||
data.addAll(getPredictionData(displayedPredictionData))
|
||||
CHANGES_COMMITTED.log(project, data)
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.jetbrains.changeReminder.predict.PredictionData
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.NODE_EXPANDED
|
||||
|
||||
internal class ChangeReminderNodeExpandedEvent(
|
||||
private val displayedPredictionResult: PredictionData
|
||||
) : ChangeReminderUserEvent {
|
||||
|
||||
override fun logEvent(project: Project) {
|
||||
NODE_EXPANDED.log(project, getPredictionData(displayedPredictionResult))
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.EventLogConfiguration
|
||||
import com.intellij.internal.statistic.eventLog.EventLogGroup
|
||||
import com.intellij.internal.statistic.eventLog.events.EventFields
|
||||
import com.intellij.internal.statistic.eventLog.events.EventPair
|
||||
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.jetbrains.changeReminder.predict.PredictionData
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.DISPLAYED_PREDICTION
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.EMPTY_REASON
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.GROUP
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderStatsCollector.PREDICTION_FOR_FILES
|
||||
import java.util.*
|
||||
|
||||
internal fun Collection<VirtualFile>.anonymizeVirtualFileCollection(): List<String> = this.map {
|
||||
EventLogConfiguration.getInstance().getOrCreate(GROUP.recorder).anonymize(it.path)
|
||||
}
|
||||
|
||||
internal fun Collection<FilePath>.anonymizeFilePathCollection(): List<String> = this.map {
|
||||
EventLogConfiguration.getInstance().getOrCreate(GROUP.recorder).anonymize(it.path)
|
||||
}
|
||||
|
||||
internal fun getPredictionData(predictionData: PredictionData): List<EventPair<*>> {
|
||||
val data = ArrayList<EventPair<*>>()
|
||||
when (predictionData) {
|
||||
is PredictionData.Prediction -> {
|
||||
data.add(DISPLAYED_PREDICTION.with(predictionData.predictionToDisplay.anonymizeVirtualFileCollection()))
|
||||
data.add(PREDICTION_FOR_FILES.with(predictionData.requestedFiles.anonymizeFilePathCollection()))
|
||||
}
|
||||
is PredictionData.EmptyPrediction -> {
|
||||
data.add(EMPTY_REASON.with(predictionData.reason))
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
object ChangeReminderStatsCollector : CounterUsagesCollector() {
|
||||
override fun getGroup(): EventLogGroup = GROUP
|
||||
|
||||
internal val GROUP = EventLogGroup("vcs.change.reminder", 4)
|
||||
internal val COMMITTED_FILES = EventFields.AnonymizedList("committed_files")
|
||||
internal val DISPLAYED_PREDICTION = EventFields.AnonymizedList("displayed_prediction")
|
||||
internal val CUR_MODIFIED_FILES = EventFields.AnonymizedList("cur_modified_files")
|
||||
internal val PREV_MODIFIED_FILES = EventFields.AnonymizedList("prev_modified_files")
|
||||
internal val PREDICTION_FOR_FILES = EventFields.AnonymizedList("prediction_for_files")
|
||||
internal val EMPTY_REASON = EventFields.Enum<PredictionData.EmptyPredictionReason>("empty_reason") {
|
||||
it.name.lowercase(Locale.ENGLISH)
|
||||
}
|
||||
|
||||
internal val CHANGELIST_CHANGED = GROUP.registerVarargEvent("changelist_changed",
|
||||
PREV_MODIFIED_FILES,
|
||||
DISPLAYED_PREDICTION,
|
||||
PREDICTION_FOR_FILES,
|
||||
EMPTY_REASON,
|
||||
CUR_MODIFIED_FILES)
|
||||
|
||||
internal val CHANGES_COMMITTED = GROUP.registerVarargEvent("changes_committed",
|
||||
CUR_MODIFIED_FILES,
|
||||
COMMITTED_FILES,
|
||||
DISPLAYED_PREDICTION,
|
||||
PREDICTION_FOR_FILES,
|
||||
EMPTY_REASON)
|
||||
|
||||
internal val NODE_EXPANDED = GROUP.registerVarargEvent("node_expanded",
|
||||
DISPLAYED_PREDICTION,
|
||||
PREDICTION_FOR_FILES,
|
||||
EMPTY_REASON)
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.events.EventPair
|
||||
import com.intellij.internal.statistic.eventLog.events.VarargEventId
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
internal interface ChangeReminderUserEvent {
|
||||
fun logEvent(project: Project)
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.changeReminder.stats.commit
|
||||
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil
|
||||
import com.intellij.openapi.vcs.changes.CommitContext
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandler
|
||||
import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory
|
||||
import com.jetbrains.changeReminder.predict.PredictionService
|
||||
import com.jetbrains.changeReminder.stats.ChangeReminderChangesCommittedEvent
|
||||
import git4idea.GitVcs
|
||||
|
||||
class ChangeReminderStatsCheckinHandler : VcsCheckinHandlerFactory(GitVcs.getKey()) {
|
||||
override fun createVcsHandler(panel: CheckinProjectPanel, commitContext: CommitContext) = object : CheckinHandler() {
|
||||
override fun beforeCheckin(): ReturnResult {
|
||||
val project = panel.project
|
||||
val prediction = project.service<PredictionService>().predictionDataToDisplay
|
||||
val committedFiles = panel.selectedChanges.map { ChangesUtil.getFilePath(it) }
|
||||
|
||||
val curFiles = ChangeListManager.getInstance(project).defaultChangeList.changes.map { ChangesUtil.getFilePath(it) }
|
||||
ChangeReminderChangesCommittedEvent(curFiles, committedFiles, prediction).logEvent(project)
|
||||
return ReturnResult.COMMIT
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user