Commit 6d4d248e authored by Kerri Miller's avatar Kerri Miller Committed by Robert Speicher

Add MR title & desc tracking events

Add basic tracking events for MR title and description changes
parent 29cc6466
......@@ -87,8 +87,23 @@ module MergeRequests
MergeRequests::CloseService
end
def before_update(issuable, skip_spam_check: false)
return unless issuable.changed?
@issuable_changes = issuable.changes
end
def after_update(issuable)
issuable.cache_merge_request_closes_issues!(current_user)
return unless @issuable_changes
%w(title description).each do |action|
next unless @issuable_changes.key?(action)
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter
.public_send("track_#{action}_edit_action".to_sym, user: current_user) # rubocop:disable GitlabSecurity/PublicSend
end
end
private
......
---
name: usage_data_i_code_review_edit_mr_desc
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/292830
rollout_issue_url:
milestone: '13.9'
type: development
group: group::code review
default_enabled: true
---
name: usage_data_i_code_review_edit_mr_title
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/292830
rollout_issue_url:
milestone: '13.9'
type: development
group: group::code review
default_enabled: true
......@@ -496,6 +496,16 @@
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_unresolve_thread
- name: i_code_review_edit_mr_title
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_edit_mr_title
- name: i_code_review_edit_mr_desc
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_edit_mr_desc
- name: i_code_review_user_merge_mr
redis_slot: code_review
category: code_review
......
......@@ -24,6 +24,8 @@ module Gitlab
MR_UNRESOLVE_THREAD_ACTION = 'i_code_review_user_unresolve_thread'
MR_ASSIGNED_USERS_ACTION = 'i_code_review_user_assigned'
MR_REVIEW_REQUESTED_USERS_ACTION = 'i_code_review_user_review_requested'
MR_EDIT_MR_TITLE_ACTION = 'i_code_review_edit_mr_title'
MR_EDIT_MR_DESC_ACTION = 'i_code_review_edit_mr_desc'
class << self
def track_mr_diffs_action(merge_request:)
......@@ -98,6 +100,14 @@ module Gitlab
track_unique_action_by_users(MR_REVIEW_REQUESTED_USERS_ACTION, users)
end
def track_title_edit_action(user:)
track_unique_action_by_user(MR_EDIT_MR_TITLE_ACTION, user)
end
def track_description_edit_action(user:)
track_unique_action_by_user(MR_EDIT_MR_DESC_ACTION, user)
end
private
def track_unique_action_by_merge_request(action, merge_request)
......
......@@ -89,6 +89,22 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl
end
end
describe '.track_title_edit_action' do
subject { described_class.track_title_edit_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_EDIT_MR_TITLE_ACTION }
end
end
describe '.track_description_edit_action' do
subject { described_class.track_description_edit_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_EDIT_MR_DESC_ACTION }
end
end
describe '.track_create_comment_action' do
subject { described_class.track_create_comment_action(note: note) }
......
......@@ -87,6 +87,19 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
expect(@merge_request.discussion_locked).to be_truthy
end
context 'usage counters' do
let(:merge_request2) { create(:merge_request) }
it 'update as expected' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_title_edit_action).once.with(user: user)
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_description_edit_action).once.with(user: user)
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request2)
end
end
context 'updating milestone' do
RSpec.shared_examples 'updates milestone' do
it 'sets milestone' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment