Commit 91b6bb64 authored by Robert Speicher's avatar Robert Speicher

Merge branch '292253-track-epic-set-parent' into 'master'

Track epic parent changes via usage ping

See merge request gitlab-org/gitlab!60079
parents cf5e9f0f f2966343
...@@ -10724,6 +10724,30 @@ Status: `implemented` ...@@ -10724,6 +10724,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate` Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_parent_monthly`
Counts of MAU updating parent on epic
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210423011841_g_project_management_users_updating_epic_parent_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_parent_weekly`
Counts of WAU updating parent on epic
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210423012053_g_project_management_users_updating_epic_parent_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_titles_monthly` ### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_titles_monthly`
Counts of MAU changing epic titles Counts of MAU changing epic titles
......
...@@ -29,13 +29,25 @@ module Epics ...@@ -29,13 +29,25 @@ module Epics
def assign_parent_epic_for(epic) def assign_parent_epic_for(epic)
return unless parent_epic return unless parent_epic
EpicLinks::CreateService.new(parent_epic, current_user, { target_issuable: epic }).execute result = EpicLinks::CreateService.new(parent_epic, current_user, { target_issuable: epic }).execute
unless result[:status] == :error
track_epic_parent_updated
end
result
end end
def assign_child_epic_for(epic) def assign_child_epic_for(epic)
return unless child_epic return unless child_epic
EpicLinks::CreateService.new(epic, current_user, { target_issuable: child_epic }).execute result = EpicLinks::CreateService.new(epic, current_user, { target_issuable: child_epic }).execute
unless result[:status] == :error
track_epic_parent_updated
end
result
end end
def available_labels def available_labels
...@@ -58,5 +70,9 @@ module Epics ...@@ -58,5 +70,9 @@ module Epics
def reopen_service def reopen_service
Epics::ReopenService Epics::ReopenService
end end
def track_epic_parent_updated
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_parent_updated_action(author: current_user)
end
end end
end end
---
title: Track epic parent changes via usage ping
merge_request: 60079
author:
type: other
---
# Name of this metric contains g_project_management prefix
# because we are using the same slot from issue_tracking to
# allow data aggregation.
key_path: redis_hll_counters.epics_usage.g_project_management_users_updating_epic_parent_monthly
description: Counts of MAU updating parent on epic
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60079
time_frame: 28d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
---
# Name of this metric contains g_project_management prefix
# because we are using the same slot from issue_tracking to
# allow data aggregation.
key_path: redis_hll_counters.epics_usage.g_project_management_users_updating_epic_parent_weekly
description: Counts of WAU updating parent on epic
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60079
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
...@@ -23,6 +23,7 @@ module Gitlab ...@@ -23,6 +23,7 @@ module Gitlab
EPIC_ISSUE_ADDED = 'g_project_management_epic_issue_added' EPIC_ISSUE_ADDED = 'g_project_management_epic_issue_added'
EPIC_ISSUE_REMOVED = 'g_project_management_epic_issue_removed' EPIC_ISSUE_REMOVED = 'g_project_management_epic_issue_removed'
EPIC_ISSUE_MOVED_FROM_PROJECT = 'g_project_management_epic_issue_moved_from_project' EPIC_ISSUE_MOVED_FROM_PROJECT = 'g_project_management_epic_issue_moved_from_project'
EPIC_PARENT_UPDATED = 'g_project_management_users_updating_epic_parent'
EPIC_CLOSED = 'g_project_management_epic_closed' EPIC_CLOSED = 'g_project_management_epic_closed'
EPIC_REOPENED = 'g_project_management_epic_reopened' EPIC_REOPENED = 'g_project_management_epic_reopened'
ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic' ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic'
...@@ -98,6 +99,10 @@ module Gitlab ...@@ -98,6 +99,10 @@ module Gitlab
track_unique_action(EPIC_ISSUE_MOVED_FROM_PROJECT, author) track_unique_action(EPIC_ISSUE_MOVED_FROM_PROJECT, author)
end end
def track_epic_parent_updated_action(author:)
track_unique_action(EPIC_PARENT_UPDATED, author)
end
def track_epic_closed_action(author:) def track_epic_closed_action(author:)
track_unique_action(EPIC_CLOSED, author) track_unique_action(EPIC_CLOSED, author)
end end
......
...@@ -256,6 +256,18 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl ...@@ -256,6 +256,18 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end end
context 'updating epic parent' do
def track_action(params)
described_class.track_epic_parent_updated_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_PARENT_UPDATED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for promoting issue to epic' do context 'for promoting issue to epic' do
def track_action(params) def track_action(params)
described_class.track_issue_promoted_to_epic(**params) described_class.track_issue_promoted_to_epic(**params)
......
...@@ -460,6 +460,7 @@ RSpec.describe Epics::UpdateService do ...@@ -460,6 +460,7 @@ RSpec.describe Epics::UpdateService do
context 'for /parent_epic' do context 'for /parent_epic' do
it 'assigns parent epic' do it 'assigns parent epic' do
parent_epic = create(:epic, group: epic.group) parent_epic = create(:epic, group: epic.group)
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_parent_updated_action)
update_epic(description: "/parent_epic #{parent_epic.to_reference}") update_epic(description: "/parent_epic #{parent_epic.to_reference}")
...@@ -470,6 +471,7 @@ RSpec.describe Epics::UpdateService do ...@@ -470,6 +471,7 @@ RSpec.describe Epics::UpdateService do
it 'does not update parent epic' do it 'does not update parent epic' do
other_group = create(:group, :private) other_group = create(:group, :private)
parent_epic = create(:epic, group: other_group) parent_epic = create(:epic, group: other_group)
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).not_to receive(:track_epic_parent_updated_action)
update_epic(description: "/parent_epic #{parent_epic.to_reference(group)}") update_epic(description: "/parent_epic #{parent_epic.to_reference(group)}")
...@@ -481,6 +483,7 @@ RSpec.describe Epics::UpdateService do ...@@ -481,6 +483,7 @@ RSpec.describe Epics::UpdateService do
context 'for /child_epic' do context 'for /child_epic' do
it 'sets a child epic' do it 'sets a child epic' do
child_epic = create(:epic, group: group) child_epic = create(:epic, group: group)
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_parent_updated_action)
update_epic(description: "/child_epic #{child_epic.to_reference}") update_epic(description: "/child_epic #{child_epic.to_reference}")
...@@ -491,6 +494,7 @@ RSpec.describe Epics::UpdateService do ...@@ -491,6 +494,7 @@ RSpec.describe Epics::UpdateService do
it 'does not set child epic' do it 'does not set child epic' do
other_group = create(:group, :private) other_group = create(:group, :private)
child_epic = create(:epic, group: other_group) child_epic = create(:epic, group: other_group)
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).not_to receive(:track_epic_parent_updated_action)
update_epic(description: "/child_epic #{child_epic.to_reference(group)}") update_epic(description: "/child_epic #{child_epic.to_reference(group)}")
expect(epic.reload.children).to be_empty expect(epic.reload.children).to be_empty
......
...@@ -103,6 +103,8 @@ ...@@ -103,6 +103,8 @@
aggregation: daily aggregation: daily
feature_flag: track_epics_activity feature_flag: track_epics_activity
# relationships
- name: g_project_management_epic_issue_added - name: g_project_management_epic_issue_added
category: epics_usage category: epics_usage
redis_slot: project_management redis_slot: project_management
...@@ -121,6 +123,12 @@ ...@@ -121,6 +123,12 @@
aggregation: daily aggregation: daily
feature_flag: track_epics_activity feature_flag: track_epics_activity
- name: g_project_management_users_updating_epic_parent
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_epic_closed - name: g_project_management_epic_closed
category: epics_usage category: epics_usage
redis_slot: project_management redis_slot: project_management
......
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