diff --git a/platform/vcs-impl/resources/META-INF/VcsExtensions.xml b/platform/vcs-impl/resources/META-INF/VcsExtensions.xml index 423f6d02546e..d20ed83ec1bc 100644 --- a/platform/vcs-impl/resources/META-INF/VcsExtensions.xml +++ b/platform/vcs-impl/resources/META-INF/VcsExtensions.xml @@ -348,6 +348,7 @@ + @@ -368,6 +369,7 @@ + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkCollector.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkCollector.kt new file mode 100644 index 000000000000..14e56f67e69d --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkCollector.kt @@ -0,0 +1,29 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.vcs.ex.commit + +import com.intellij.internal.statistic.eventLog.EventLogGroup +import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector + +internal object CommitChunkCollector : CounterUsagesCollector() { + private val group = EventLogGroup("vcs.commit.chunk", 1) + + override fun getGroup(): EventLogGroup = group + + private val IS_AMEND = EventFields.Boolean("amend") + + private val CHUNK_LINES_COUNT = EventFields.RoundedInt("chunk_lines") // 0 - DELETED + private val MESSAGE_LINES_COUNT = EventFields.RoundedInt("message_lines") + private val MESSAGE_SUBJECT_LENGTH = EventFields.RoundedInt("message_subject_length") + + private val COMMIT = group.registerVarargEvent("commit", IS_AMEND, CHUNK_LINES_COUNT, MESSAGE_LINES_COUNT, MESSAGE_SUBJECT_LENGTH) + + fun logCommit(isAmend: Boolean, linesChanged: Int, messageLinesCount: Int, messageSubjectLength: Int) { + COMMIT.log( + IS_AMEND.with(isAmend), + CHUNK_LINES_COUNT.with(linesChanged), + MESSAGE_LINES_COUNT.with(messageLinesCount), + MESSAGE_SUBJECT_LENGTH.with(messageSubjectLength) + ) + } +} \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkComponent.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkComponent.kt index 7af19bd5f34b..bccaf31555c4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkComponent.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/commit/CommitChunkComponent.kt @@ -208,6 +208,7 @@ private class CommitChunkPanel(private val tracker: ChangelistsLocalLineStatusTr private class CommitChunkWorkflow(project: Project) : NonModalCommitWorkflow(project) { lateinit var state: ChangeListCommitState + lateinit var range: LocalRange init { val vcses = ProjectLevelVcsManager.getInstance(project).allActiveVcss.toSet() @@ -221,8 +222,19 @@ private class CommitChunkWorkflow(project: Project) : NonModalCommitWorkflow(pro val committer = LocalChangesCommitter(project, state, commitContext) addCommonResultHandlers(sessionInfo, committer) committer.addResultHandler(ShowNotificationCommitResultHandler(committer)) + logCommit() committer.runCommit(VcsBundle.message("commit.changes"), false) } + + private fun logCommit() { + val message = state.commitMessage + val messageLines = message.lines().filter { it.isNotBlank() } + val subjectLength = messageLines.getOrNull(0)?.length ?: 0 + + val lines = range.line2 - range.line1 + + CommitChunkCollector.logCommit(commitContext.isAmendCommitMode, lines, messageLines.size, subjectLength) + } } private class CommitChunkWorkFlowHandler( @@ -256,6 +268,7 @@ private class CommitChunkWorkFlowHandler( override suspend fun updateWorkflow(sessionInfo: CommitSessionInfo): Boolean { workflow.state = getCommitState() + workflow.range = rangeProvider() return true }