Commit f2966343 authored by charlie ablett's avatar charlie ablett

Track epic parent changes via usage ping

- add dictionary update
- add tests

Changelog: other
parent 24909597
......@@ -10280,6 +10280,30 @@ Status: `implemented`
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`
Counts of MAU changing epic titles
......
......@@ -29,13 +29,25 @@ module Epics
def assign_parent_epic_for(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
def assign_child_epic_for(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
def available_labels
......@@ -58,5 +70,9 @@ module Epics
def reopen_service
Epics::ReopenService
end
def track_epic_parent_updated
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_parent_updated_action(author: current_user)
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
......@@ -22,6 +22,7 @@ module Gitlab
EPIC_ISSUE_ADDED = 'g_project_management_epic_issue_added'
EPIC_ISSUE_REMOVED = 'g_project_management_epic_issue_removed'
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_REOPENED = 'g_project_management_epic_reopened'
ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic'
......@@ -91,6 +92,10 @@ module Gitlab
track_unique_action(EPIC_ISSUE_MOVED_FROM_PROJECT, author)
end
def track_epic_parent_updated_action(author:)
track_unique_action(EPIC_PARENT_UPDATED, author)
end
def track_epic_closed_action(author:)
track_unique_action(EPIC_CLOSED, author)
end
......
......@@ -246,6 +246,18 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
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
def track_action(params)
described_class.track_issue_promoted_to_epic(**params)
......
......@@ -447,6 +447,7 @@ RSpec.describe Epics::UpdateService do
context 'for /parent_epic' do
it 'assigns parent epic' do
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}")
......@@ -457,6 +458,7 @@ RSpec.describe Epics::UpdateService do
it 'does not update parent epic' do
other_group = create(:group, :private)
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)}")
......@@ -468,6 +470,7 @@ RSpec.describe Epics::UpdateService do
context 'for /child_epic' do
it 'sets a child epic' do
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}")
......@@ -478,6 +481,7 @@ RSpec.describe Epics::UpdateService do
it 'does not set child epic' do
other_group = create(:group, :private)
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)}")
expect(epic.reload.children).to be_empty
......
......@@ -81,6 +81,8 @@
aggregation: daily
feature_flag: track_epics_activity
# relationships
- name: g_project_management_epic_issue_added
category: epics_usage
redis_slot: project_management
......@@ -99,6 +101,12 @@
aggregation: daily
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
category: epics_usage
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