Commit 26b813ce authored by Thong Kuah's avatar Thong Kuah

Merge branch '292824-track-assignee-reviewer-changes' into 'master'

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

See merge request gitlab-org/gitlab!55486
parents 75a041b5 e5123750
...@@ -205,6 +205,7 @@ module MergeRequests ...@@ -205,6 +205,7 @@ module MergeRequests
new_assignees = merge_request.assignees - old_assignees new_assignees = merge_request.assignees - old_assignees
merge_request_activity_counter.track_users_assigned_to_mr(users: new_assignees) merge_request_activity_counter.track_users_assigned_to_mr(users: new_assignees)
merge_request_activity_counter.track_assignees_changed_action(user: current_user)
end end
def handle_reviewers_change(merge_request, old_reviewers) def handle_reviewers_change(merge_request, old_reviewers)
...@@ -216,6 +217,7 @@ module MergeRequests ...@@ -216,6 +217,7 @@ module MergeRequests
new_reviewers = merge_request.reviewers - old_reviewers new_reviewers = merge_request.reviewers - old_reviewers
merge_request_activity_counter.track_users_review_requested(users: new_reviewers) merge_request_activity_counter.track_users_review_requested(users: new_reviewers)
merge_request_activity_counter.track_reviewers_changed_action(user: current_user)
end end
def create_branch_change_note(issuable, branch_type, event_type, old_branch, new_branch) def create_branch_change_note(issuable, branch_type, event_type, old_branch, new_branch)
......
---
title: Add tracking to merge request assignees/reviewers changes
merge_request: 55486
author:
type: other
---
name: usage_data_i_code_review_user_assignees_changed
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486
rollout_issue_url:
milestone: '13.10'
type: development
group: group::code review
default_enabled: true
---
name: usage_data_i_code_review_user_reviewers_changed
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486
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_assignees_changed_monthly
description: Count of unique users per month who changed assignees 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/55486
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_reviewers_changed_monthly
description: Count of unique users per month who changed reviewers 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/55486
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_assignees_changed_weekly
description: Count of unique users per week who changed assignees 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/55486
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_reviewers_changed_weekly
description: Count of unique users per week who changed reviewers 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/55486
time_frame: 7d
data_source: redis_hll
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
...@@ -13004,6 +13004,46 @@ Missing description ...@@ -13004,6 +13004,46 @@ Missing description
| `tier` | | | `tier` | |
| `skip_validation` | true | | `skip_validation` | true |
## `redis_hll_counters.code_review.i_code_review_user_assignees_changed_monthly`
Count of unique users per month who changed assignees of a MR
| field | value |
| --- | --- |
| `key_path` | **`redis_hll_counters.code_review.i_code_review_user_assignees_changed_monthly`** |
| `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` | [Introduced by](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486) |
| `time_frame` | 28d |
| `data_source` | Redis_hll |
| `distribution` | ce, ee |
| `tier` | free, premium, ultimate |
## `redis_hll_counters.code_review.i_code_review_user_assignees_changed_weekly`
Count of unique users per week who changed assignees of a MR
| field | value |
| --- | --- |
| `key_path` | **`redis_hll_counters.code_review.i_code_review_user_assignees_changed_weekly`** |
| `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` | [Introduced by](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486) |
| `time_frame` | 7d |
| `data_source` | Redis_hll |
| `distribution` | ce, ee |
| `tier` | free, premium, ultimate |
## `redis_hll_counters.code_review.i_code_review_user_close_mr_monthly` ## `redis_hll_counters.code_review.i_code_review_user_close_mr_monthly`
Count of unique users per week|month who closed a MR Count of unique users per week|month who closed a MR
...@@ -13692,6 +13732,46 @@ Missing description ...@@ -13692,6 +13732,46 @@ Missing description
| `tier` | | | `tier` | |
| `skip_validation` | true | | `skip_validation` | true |
## `redis_hll_counters.code_review.i_code_review_user_reviewers_changed_monthly`
Count of unique users per month who changed reviewers of a MR
| field | value |
| --- | --- |
| `key_path` | **`redis_hll_counters.code_review.i_code_review_user_reviewers_changed_monthly`** |
| `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` | [Introduced by](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486) |
| `time_frame` | 28d |
| `data_source` | Redis_hll |
| `distribution` | ce, ee |
| `tier` | free, premium, ultimate |
## `redis_hll_counters.code_review.i_code_review_user_reviewers_changed_weekly`
Count of unique users per week who changed reviewers of a MR
| field | value |
| --- | --- |
| `key_path` | **`redis_hll_counters.code_review.i_code_review_user_reviewers_changed_weekly`** |
| `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` | [Introduced by](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55486) |
| `time_frame` | 7d |
| `data_source` | Redis_hll |
| `distribution` | ce, ee |
| `tier` | free, premium, ultimate |
## `redis_hll_counters.code_review.i_code_review_user_single_file_diffs_monthly` ## `redis_hll_counters.code_review.i_code_review_user_single_file_diffs_monthly`
Count of unique users per week|month with diffs viewed file by file Count of unique users per week|month with diffs viewed file by file
......
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
'i_code_review_user_mr_discussion_locked', 'i_code_review_user_mr_discussion_locked',
'i_code_review_user_mr_discussion_unlocked', 'i_code_review_user_mr_discussion_unlocked',
'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_reviewers_changed'
] ]
- name: code_review_category_monthly_active_users - name: code_review_category_monthly_active_users
operator: OR operator: OR
...@@ -86,7 +88,9 @@ ...@@ -86,7 +88,9 @@
'i_code_review_user_mr_discussion_locked', 'i_code_review_user_mr_discussion_locked',
'i_code_review_user_mr_discussion_unlocked', 'i_code_review_user_mr_discussion_unlocked',
'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_reviewers_changed'
] ]
- name: code_review_extension_category_monthly_active_users - name: code_review_extension_category_monthly_active_users
operator: OR operator: OR
......
...@@ -184,3 +184,13 @@ ...@@ -184,3 +184,13 @@
category: code_review category: code_review
aggregation: weekly aggregation: weekly
feature_flag: usage_data_i_code_review_user_time_spent_changed feature_flag: usage_data_i_code_review_user_time_spent_changed
- name: i_code_review_user_assignees_changed
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_assignees_changed
- name: i_code_review_user_reviewers_changed
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_reviewers_changed
...@@ -39,6 +39,8 @@ module Gitlab ...@@ -39,6 +39,8 @@ module Gitlab
MR_DISCUSSION_UNLOCKED_ACTION = 'i_code_review_user_mr_discussion_unlocked' MR_DISCUSSION_UNLOCKED_ACTION = 'i_code_review_user_mr_discussion_unlocked'
MR_TIME_ESTIMATE_CHANGED_ACTION = 'i_code_review_user_time_estimate_changed' MR_TIME_ESTIMATE_CHANGED_ACTION = 'i_code_review_user_time_estimate_changed'
MR_TIME_SPENT_CHANGED_ACTION = 'i_code_review_user_time_spent_changed' MR_TIME_SPENT_CHANGED_ACTION = 'i_code_review_user_time_spent_changed'
MR_ASSIGNEES_CHANGED_ACTION = 'i_code_review_user_assignees_changed'
MR_REVIEWERS_CHANGED_ACTION = 'i_code_review_user_reviewers_changed'
class << self class << self
def track_mr_diffs_action(merge_request:) def track_mr_diffs_action(merge_request:)
...@@ -173,6 +175,14 @@ module Gitlab ...@@ -173,6 +175,14 @@ module Gitlab
track_unique_action_by_user(MR_TIME_SPENT_CHANGED_ACTION, user) track_unique_action_by_user(MR_TIME_SPENT_CHANGED_ACTION, user)
end end
def track_assignees_changed_action(user:)
track_unique_action_by_user(MR_ASSIGNEES_CHANGED_ACTION, user)
end
def track_reviewers_changed_action(user:)
track_unique_action_by_user(MR_REVIEWERS_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)
......
...@@ -316,4 +316,20 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl ...@@ -316,4 +316,20 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl
let(:action) { described_class::MR_TIME_SPENT_CHANGED_ACTION } let(:action) { described_class::MR_TIME_SPENT_CHANGED_ACTION }
end end
end end
describe '.track_assignees_changed_action' do
subject { described_class.track_assignees_changed_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_ASSIGNEES_CHANGED_ACTION }
end
end
describe '.track_reviewers_changed_action' do
subject { described_class.track_reviewers_changed_action(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_REVIEWERS_CHANGED_ACTION }
end
end
end end
...@@ -186,6 +186,54 @@ RSpec.describe MergeRequests::UpdateService, :mailer do ...@@ -186,6 +186,54 @@ 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
context 'assignees' do
context 'when assignees changed' do
it 'tracks assignees changed event' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_assignees_changed_action).once.with(user: user)
opts[:assignees] = [user2]
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
context 'when assignees did not change' do
it 'does not track assignees changed event' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.not_to receive(:track_assignees_changed_action)
opts[:assignees] = merge_request.assignees
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
end
context 'reviewers' do
context 'when reviewers changed' do
it 'tracks reviewers changed event' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_reviewers_changed_action).once.with(user: user)
opts[:reviewers] = [user2]
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
context 'when reviewers did not change' do
it 'does not track reviewers changed event' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.not_to receive(:track_reviewers_changed_action)
opts[:reviewers] = merge_request.reviewers
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
end
end end
context 'updating milestone' do context 'updating 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