Commit c5a0b656 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '292824-track-label-milestone-change' into 'master'

Add tracking to merge request labels/milestone changes [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!55484
parents 4354b17a f8b0a910
...@@ -50,6 +50,7 @@ module MergeRequests ...@@ -50,6 +50,7 @@ module MergeRequests
track_title_and_desc_edits(changed_fields) track_title_and_desc_edits(changed_fields)
track_discussion_lock_toggle(merge_request, changed_fields) track_discussion_lock_toggle(merge_request, changed_fields)
track_time_estimate_and_spend_edits(merge_request, old_timelogs, changed_fields) track_time_estimate_and_spend_edits(merge_request, old_timelogs, changed_fields)
track_labels_change(merge_request, old_labels)
notify_if_labels_added(merge_request, old_labels) notify_if_labels_added(merge_request, old_labels)
notify_if_mentions_added(merge_request, old_mentioned_users) notify_if_mentions_added(merge_request, old_mentioned_users)
...@@ -113,6 +114,12 @@ module MergeRequests ...@@ -113,6 +114,12 @@ module MergeRequests
merge_request_activity_counter.track_time_spent_changed_action(user: current_user) if old_timelogs != merge_request.timelogs merge_request_activity_counter.track_time_spent_changed_action(user: current_user) if old_timelogs != merge_request.timelogs
end end
def track_labels_change(merge_request, old_labels)
return if Set.new(merge_request.labels) == Set.new(old_labels)
merge_request_activity_counter.track_labels_changed_action(user: current_user)
end
def notify_if_labels_added(merge_request, old_labels) def notify_if_labels_added(merge_request, old_labels)
added_labels = merge_request.labels - old_labels added_labels = merge_request.labels - old_labels
...@@ -191,6 +198,8 @@ module MergeRequests ...@@ -191,6 +198,8 @@ module MergeRequests
return unless merge_request.previous_changes.include?('milestone_id') return unless merge_request.previous_changes.include?('milestone_id')
merge_request_activity_counter.track_milestone_changed_action(user: current_user)
if merge_request.milestone.nil? if merge_request.milestone.nil?
notification_service.async.removed_milestone_merge_request(merge_request, current_user) notification_service.async.removed_milestone_merge_request(merge_request, current_user)
else else
......
---
title: Add tracking to merge request labels/milestone changes
merge_request: 55484
author:
type: other
---
name: usage_data_i_code_review_user_labels_changed
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
rollout_issue_url:
milestone: '13.10'
type: development
group: group::code review
default_enabled: true
---
name: usage_data_i_code_review_user_milestone_changed
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
rollout_issue_url:
milestone: '13.10'
type: development
group: group::code review
default_enabled: true
---
key_path: redis_hll_counters.code_review.i_code_review_user_milestone_changed_monthly
description: Count of unique users per month who changed milestone of a MR
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
time_frame: 28d
data_source: redis_hll
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_user_labels_changed_monthly
description: Count of unique users per month who changed labels of a MR
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
time_frame: 28d
data_source: redis_hll
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_user_milestone_changed_weekly
description: Count of unique users per week who changed milestone of a MR
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
time_frame: 7d
data_source: redis_hll
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_user_labels_changed_weekly
description: Count of unique users per week who changed labels of a MR
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55484
time_frame: 7d
data_source: redis_hll
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
...@@ -8468,6 +8468,30 @@ Status: `data_available` ...@@ -8468,6 +8468,30 @@ Status: `data_available`
Tiers: Tiers:
### `redis_hll_counters.code_review.i_code_review_user_labels_changed_monthly`
Count of unique users per month who changed labels of a MR
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210302110607_i_code_review_user_labels_changed_monthly.yml)
Group: `group::code review`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.code_review.i_code_review_user_labels_changed_weekly`
Count of unique users per week who changed labels of a MR
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302110548_i_code_review_user_labels_changed_weekly.yml)
Group: `group::code review`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.code_review.i_code_review_user_marked_as_draft_monthly` ### `redis_hll_counters.code_review.i_code_review_user_marked_as_draft_monthly`
Missing description Missing description
...@@ -8516,6 +8540,30 @@ Status: `data_available` ...@@ -8516,6 +8540,30 @@ Status: `data_available`
Tiers: Tiers:
### `redis_hll_counters.code_review.i_code_review_user_milestone_changed_monthly`
Count of unique users per month who changed milestone of a MR
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210302110520_i_code_review_user_milestone_changed_monthly.yml)
Group: `group::code review`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.code_review.i_code_review_user_milestone_changed_weekly`
Count of unique users per week who changed milestone of a MR
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302110403_i_code_review_user_milestone_changed_weekly.yml)
Group: `group::code review`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.code_review.i_code_review_user_mr_discussion_locked_monthly` ### `redis_hll_counters.code_review.i_code_review_user_mr_discussion_locked_monthly`
Count of unique users per month who locked a MR Count of unique users per month who locked a MR
......
...@@ -49,7 +49,9 @@ ...@@ -49,7 +49,9 @@
'i_code_review_user_time_estimate_changed', 'i_code_review_user_time_estimate_changed',
'i_code_review_user_time_spent_changed', 'i_code_review_user_time_spent_changed',
'i_code_review_user_assignees_changed', 'i_code_review_user_assignees_changed',
'i_code_review_user_reviewers_changed' 'i_code_review_user_reviewers_changed',
'i_code_review_user_milestone_changed',
'i_code_review_user_labels_changed'
] ]
- name: code_review_category_monthly_active_users - name: code_review_category_monthly_active_users
operator: OR operator: OR
...@@ -92,7 +94,9 @@ ...@@ -92,7 +94,9 @@
'i_code_review_user_time_estimate_changed', 'i_code_review_user_time_estimate_changed',
'i_code_review_user_time_spent_changed', 'i_code_review_user_time_spent_changed',
'i_code_review_user_assignees_changed', 'i_code_review_user_assignees_changed',
'i_code_review_user_reviewers_changed' 'i_code_review_user_reviewers_changed',
'i_code_review_user_milestone_changed',
'i_code_review_user_labels_changed'
] ]
- name: code_review_extension_category_monthly_active_users - name: code_review_extension_category_monthly_active_users
operator: OR operator: OR
......
...@@ -194,3 +194,13 @@ ...@@ -194,3 +194,13 @@
category: code_review category: code_review
aggregation: weekly aggregation: weekly
feature_flag: usage_data_i_code_review_user_reviewers_changed feature_flag: usage_data_i_code_review_user_reviewers_changed
- name: i_code_review_user_milestone_changed
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_milestone_changed
- name: i_code_review_user_labels_changed
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_labels_changed
...@@ -42,6 +42,8 @@ module Gitlab ...@@ -42,6 +42,8 @@ module Gitlab
MR_ASSIGNEES_CHANGED_ACTION = 'i_code_review_user_assignees_changed' MR_ASSIGNEES_CHANGED_ACTION = 'i_code_review_user_assignees_changed'
MR_REVIEWERS_CHANGED_ACTION = 'i_code_review_user_reviewers_changed' MR_REVIEWERS_CHANGED_ACTION = 'i_code_review_user_reviewers_changed'
MR_INCLUDING_CI_CONFIG_ACTION = 'o_pipeline_authoring_unique_users_pushing_mr_ciconfigfile' MR_INCLUDING_CI_CONFIG_ACTION = 'o_pipeline_authoring_unique_users_pushing_mr_ciconfigfile'
MR_MILESTONE_CHANGED_ACTION = 'i_code_review_user_milestone_changed'
MR_LABELS_CHANGED_ACTION = 'i_code_review_user_labels_changed'
class << self class << self
def track_mr_diffs_action(merge_request:) def track_mr_diffs_action(merge_request:)
...@@ -191,6 +193,14 @@ module Gitlab ...@@ -191,6 +193,14 @@ module Gitlab
track_unique_action_by_user(MR_INCLUDING_CI_CONFIG_ACTION, user) track_unique_action_by_user(MR_INCLUDING_CI_CONFIG_ACTION, user)
end end
def track_milestone_changed_action(user:)
track_unique_action_by_user(MR_MILESTONE_CHANGED_ACTION, user)
end
def track_labels_changed_action(user:)
track_unique_action_by_user(MR_LABELS_CHANGED_ACTION, user)
end
private private
def track_unique_action_by_merge_request(action, merge_request) def track_unique_action_by_merge_request(action, merge_request)
......
...@@ -370,4 +370,20 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl ...@@ -370,4 +370,20 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl
it_behaves_like 'not tracked merge request unique event' it_behaves_like 'not tracked merge request unique event'
end end
end end
describe '.track_milestone_changed_action' do
subject { described_class.track_milestone_changed_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_MILESTONE_CHANGED_ACTION }
end
end
describe '.track_labels_changed_action' do
subject { described_class.track_labels_changed_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_LABELS_CHANGED_ACTION }
end
end
end end
...@@ -187,6 +187,24 @@ RSpec.describe MergeRequests::UpdateService, :mailer do ...@@ -187,6 +187,24 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end end
it 'tracks milestone change' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_milestone_changed_action).once.with(user: user)
opts[:milestone] = milestone
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
it 'track labels change' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_labels_changed_action).once.with(user: user)
opts[:label_ids] = [label2.id]
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
context 'assignees' do context 'assignees' do
context 'when assignees changed' do context 'when assignees changed' do
it 'tracks assignees changed event' do it 'tracks assignees changed event' 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