diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/GHPRStatisticsCollector.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/GHPRStatisticsCollector.kt index 4995d6f28905..a65363f6346e 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/GHPRStatisticsCollector.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/GHPRStatisticsCollector.kt @@ -26,7 +26,7 @@ import java.util.* // TODO: Fix or replace a whole bunch of these statistics as they're no longer being collected since generalizing to Collab Tools internal object GHPRStatisticsCollector : CounterUsagesCollector() { - private val COUNTERS_GROUP = EventLogGroup("vcs.github.pullrequest.counters", 11) + private val COUNTERS_GROUP = EventLogGroup("vcs.github.pullrequest.counters", 12) private val LOG = logger() @@ -45,9 +45,13 @@ internal object GHPRStatisticsCollector : CounterUsagesCollector() { } //endregion - //region: Multiline comments - private val COMMENTS_RESIZED_EVENT = COUNTERS_GROUP.registerEvent("comments.resized", "The user resized range of a new comment by dragging its outline across the text") - private val MULTILINE_COMMENTS_CREATED = COUNTERS_GROUP.registerEvent("multiline.comments.created", "The user created a new comment that spans multiple lines") + //region: Comments + private val COMMENTS_RESIZED_EVENT = COUNTERS_GROUP.registerEvent("comments.resized", + "The user resized range of a new comment by dragging its outline across the text") + private val MULTILINE_COMMENTS_CREATED = COUNTERS_GROUP.registerEvent("multiline.comments.created", + "The user created a new comment that spans multiple lines") + private val TOGGLED_COMMENTS_EVENT = COUNTERS_GROUP.registerEvent("comments.toggled", + "The user toggled visibility of comments on given line in code review") fun logResizedComments(project: Project) { COMMENTS_RESIZED_EVENT.log(project) } @@ -55,6 +59,10 @@ internal object GHPRStatisticsCollector : CounterUsagesCollector() { fun logMultilineCommentsCreated(project: Project) { MULTILINE_COMMENTS_CREATED.log(project) } + + fun logToggledComments(project: Project) { + TOGGLED_COMMENTS_EVENT.log(project) + } //endregion //region: Filters diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/diff/GHPRReviewDiffExtension.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/diff/GHPRReviewDiffExtension.kt index 2a22f70217db..462768bc3f6f 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/diff/GHPRReviewDiffExtension.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/diff/GHPRReviewDiffExtension.kt @@ -19,6 +19,7 @@ import com.intellij.diff.util.Range import com.intellij.diff.util.Side import com.intellij.openapi.components.Service import com.intellij.openapi.components.service +import com.intellij.openapi.project.Project import com.intellij.platform.util.coroutines.childScope import com.intellij.util.cancelOnDispose import com.intellij.util.concurrency.annotations.RequiresEdt @@ -28,6 +29,7 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import org.jetbrains.plugins.github.ai.GHPRAICommentViewModel +import org.jetbrains.plugins.github.pullrequest.GHPRStatisticsCollector import org.jetbrains.plugins.github.pullrequest.ui.comment.GHPRCompactReviewThreadViewModel import org.jetbrains.plugins.github.pullrequest.ui.comment.GHPRReviewCommentLocation import org.jetbrains.plugins.github.pullrequest.ui.comment.lineLocation @@ -52,7 +54,7 @@ internal class GHPRReviewDiffExtension : DiffExtension() { } @Service(Service.Level.PROJECT) - private class InlaysController(parentCs: CoroutineScope) { + private class InlaysController(private val project: Project, parentCs: CoroutineScope) { private val cs = parentCs.childScope(javaClass.name, Dispatchers.Main) fun installInlays(reviewVm: GHPRDiffViewModel, change: RefComparisonChange, viewer: DiffViewerBase) { @@ -71,7 +73,7 @@ internal class GHPRReviewDiffExtension : DiffExtension() { viewer.showCodeReview { editor, _, locationToLine, lineToLocation, lineToUnified -> coroutineScope { val cs = this - val model = DiffEditorModel(cs, reviewVm, changeVm, locationToLine, lineToLocation) { + val model = DiffEditorModel(cs, project, reviewVm, changeVm, locationToLine, lineToLocation) { val (leftLine, rightLine) = lineToUnified(it) UnifiedCodeReviewItemPosition(change, leftLine, rightLine) } @@ -98,6 +100,7 @@ internal interface GHPRReviewDiffEditorModel : CodeReviewEditorModel Int?, @@ -195,6 +198,7 @@ private class DiffEditorModel( override fun toggleComments(lineIdx: Int) { inlays.value.asSequence().filter { it.line.value == lineIdx }.filterIsInstance().syncOrToggleAll() + GHPRStatisticsCollector.logToggledComments(project) } override val canNavigate: Boolean get() = diffVm.canNavigate diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorModel.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorModel.kt index 29bf957f569d..86061eda1145 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorModel.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorModel.kt @@ -11,6 +11,7 @@ import com.intellij.diff.util.LineRange import com.intellij.diff.util.Range import com.intellij.diff.util.Side import com.intellij.openapi.Disposable +import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key import com.intellij.platform.util.coroutines.childScope import com.intellij.util.cancelOnDispose @@ -22,12 +23,14 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch +import org.jetbrains.plugins.github.pullrequest.GHPRStatisticsCollector import org.jetbrains.plugins.github.pullrequest.config.GithubPullRequestsProjectUISettings import org.jetbrains.plugins.github.pullrequest.ui.comment.GHPRReviewCommentLocation import java.util.* internal class GHPRReviewFileEditorModel internal constructor( private val cs: CoroutineScope, + private val project: Project, private val settings: GithubPullRequestsProjectUISettings, private val fileVm: GHPRReviewFileEditorViewModel, private val changesModel: MutableCodeReviewEditorGutterChangesModel = MutableCodeReviewEditorGutterChangesModel(), @@ -90,6 +93,7 @@ internal class GHPRReviewFileEditorModel internal constructor( override fun toggleComments(lineIdx: Int) { inlays.value.asSequence().filter { it.line.value == lineIdx }.filterIsInstance().syncOrToggleAll() + GHPRStatisticsCollector.logToggledComments(project) } override fun getBaseContent(lines: LineRange): String? = fileVm.getBaseContent(lines) diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewInEditorController.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewInEditorController.kt index abc5ff4cd16f..edb37512a2a1 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewInEditorController.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewInEditorController.kt @@ -99,7 +99,7 @@ private suspend fun showReview(project: Project, settings: GithubPullRequestsPro withContext(Dispatchers.Main.immediate) { val reviewHeadContent = fileVm.originalContent.mapNotNull { it?.result?.getOrThrow() }.first() val cs = this - val model = GHPRReviewFileEditorModel(cs, settings, fileVm) showEditor@{ changeToShow, lineIdx -> + val model = GHPRReviewFileEditorModel(cs, project, settings, fileVm) showEditor@{ changeToShow, lineIdx -> val file = changeToShow.filePathAfter?.virtualFile ?: return@showEditor val fileOpenDescriptor = OpenFileDescriptor(project, file, lineIdx, 0) FileEditorManager.getInstance(project).openFileEditor(fileOpenDescriptor, true) diff --git a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/diff/GitLabMergeRequestDiffExtension.kt b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/diff/GitLabMergeRequestDiffExtension.kt index aa9b099c7aeb..f47fd387746e 100644 --- a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/diff/GitLabMergeRequestDiffExtension.kt +++ b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/diff/GitLabMergeRequestDiffExtension.kt @@ -80,7 +80,7 @@ class GitLabMergeRequestDiffExtension : DiffExtension() { viewer.showCodeReview( modelFactory = { _, _, locationToLine, lineToLocations, lineToUnified -> - DiffEditorModel(this, changeVm, locationToLine, lineToLocations) { + DiffEditorModel(this, project, changeVm, locationToLine, lineToLocations) { val (leftLine, rightLine) = lineToUnified(it) UnifiedCodeReviewItemPosition(change, leftLine, rightLine) } @@ -116,6 +116,7 @@ internal interface GitLabReviewDiffEditorModel : CodeReviewEditorModel Int?, private val lineToLocation: (Int) -> DiffLineLocation?, @@ -158,6 +159,7 @@ private class DiffEditorModel( override fun toggleComments(lineIdx: Int) { inlays.value.asSequence().filter { it.line.value == lineIdx }.filterIsInstance().syncOrToggleAll() + GitLabStatistics.logToggledComments(project) } override val canNavigate: Boolean get() = diffReviewVm.isCumulativeChange diff --git a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewController.kt b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewController.kt index cde0b4e3aa66..65e45155554c 100644 --- a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewController.kt +++ b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewController.kt @@ -112,7 +112,7 @@ internal class GitLabMergeRequestEditorReviewController(private val project: Pro val preferences = project.serviceAsync() val reviewHeadContent = fileVm.headContent.mapNotNull { it?.result?.getOrThrow() }.first() - val model = GitLabMergeRequestEditorReviewUIModel(this, preferences, fileVm) showEditor@{ changeToShow, lineIdx -> + val model = GitLabMergeRequestEditorReviewUIModel(this, project, preferences, fileVm) showEditor@{ changeToShow, lineIdx -> val file = changeToShow.filePathAfter?.virtualFile ?: return@showEditor val fileOpenDescriptor = OpenFileDescriptor(project, file, lineIdx, 0) FileEditorManager.getInstance(project).openFileEditor(fileOpenDescriptor, true) diff --git a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewUIModel.kt b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewUIModel.kt index 5f2292f61250..5c24ef46c132 100644 --- a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewUIModel.kt +++ b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewUIModel.kt @@ -7,6 +7,7 @@ import com.intellij.collaboration.util.* import com.intellij.diff.util.LineRange import com.intellij.diff.util.Range import com.intellij.openapi.Disposable +import com.intellij.openapi.project.Project import com.intellij.util.cancelOnDispose import com.intellij.util.concurrency.annotations.RequiresEdt import kotlinx.coroutines.CoroutineScope @@ -15,12 +16,14 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import org.jetbrains.plugins.gitlab.mergerequest.GitLabMergeRequestsPreferences +import org.jetbrains.plugins.gitlab.util.GitLabStatistics /** * A wrapper over [GitLabMergeRequestEditorReviewFileViewModel] to encapsulate LST integration */ internal class GitLabMergeRequestEditorReviewUIModel internal constructor( private val cs: CoroutineScope, + private val project: Project, private val preferences: GitLabMergeRequestsPreferences, private val fileVm: GitLabMergeRequestEditorReviewFileViewModel, private val changesModel: MutableCodeReviewEditorGutterChangesModel = MutableCodeReviewEditorGutterChangesModel(), @@ -88,6 +91,7 @@ internal class GitLabMergeRequestEditorReviewUIModel internal constructor( override fun toggleComments(lineIdx: Int) { inlays.value.asSequence().filter { it.line.value == lineIdx }.filterIsInstance().syncOrToggleAll() + GitLabStatistics.logToggledComments(project) } fun cancelNewDiscussion(originalLine: Int) { diff --git a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/util/gitLabStatistics.kt b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/util/gitLabStatistics.kt index 794811a00001..40697d3869ca 100644 --- a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/util/gitLabStatistics.kt +++ b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/util/gitLabStatistics.kt @@ -102,7 +102,7 @@ object GitLabStatistics { //endregion //region Counters - private val COUNTERS_GROUP = EventLogGroup("vcs.gitlab.counters", version = 28) + private val COUNTERS_GROUP = EventLogGroup("vcs.gitlab.counters", version = 29) /** * Server metadata was fetched @@ -297,6 +297,12 @@ object GitLabStatistics { fun logFileUploadActionExecuted(project: Project): Unit = PROJECT_FILE_UPLOAD.log(project) + private val DISCUSSIONS_TOGGLED = COUNTERS_GROUP.registerEvent("comments.toggled", + "The user toggled visibility of discussions on given line in code review") + + fun logToggledComments(project: Project) { + DISCUSSIONS_TOGGLED.log(project) + } /** * GitLab tool window tab was opened from