Commit b7eb36d5 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '292253-counts-epic-labels' into 'master'

Track epic labels change action on usage ping

See merge request gitlab-org/gitlab!56571
parents d5acf905 edaf424a
...@@ -9956,6 +9956,30 @@ Status: `implemented` ...@@ -9956,6 +9956,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate` Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_users_changing_labels_monthly`
Count of MAU chaging the epic lables
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210312195730_g_project_management_epic_labels_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_users_changing_labels_weekly`
Count of WAU chaging the epic lables
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210312195849_g_project_management_epic_labels_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_issue_promoted_to_epic_monthly` ### `redis_hll_counters.epics_usage.g_project_management_issue_promoted_to_epic_monthly`
Count of MAU promoting issues to epics Count of MAU promoting issues to epics
......
...@@ -6,6 +6,13 @@ module EE ...@@ -6,6 +6,13 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :execute
def execute(added_labels: [], removed_labels: [])
super
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_labels_changed_action(author: user) if resource.is_a?(Epic)
end
override :resource_column override :resource_column
def resource_column(resource) def resource_column(resource)
resource.is_a?(Epic) ? :epic_id : super resource.is_a?(Epic) ? :epic_id : super
......
---
title: Track epic labels change action on usage ping
merge_request: 56571
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_epic_users_changing_labels_monthly
description: Count of MAU chaging the epic lables
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56571
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_epic_users_changing_labels_weekly
description: Count of WAU chaging the epic lables
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56571
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
...@@ -26,6 +26,7 @@ module Gitlab ...@@ -26,6 +26,7 @@ module Gitlab
ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic' ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic'
EPIC_CONFIDENTIAL = 'g_project_management_users_setting_epic_confidential' EPIC_CONFIDENTIAL = 'g_project_management_users_setting_epic_confidential'
EPIC_VISIBLE = 'g_project_management_users_setting_epic_visible' EPIC_VISIBLE = 'g_project_management_users_setting_epic_visible'
EPIC_LABELS = 'g_project_management_epic_users_changing_labels'
class << self class << self
def track_epic_created_action(author:) def track_epic_created_action(author:)
...@@ -104,6 +105,10 @@ module Gitlab ...@@ -104,6 +105,10 @@ module Gitlab
track_unique_action(EPIC_VISIBLE, author) track_unique_action(EPIC_VISIBLE, author)
end end
def track_epic_labels_changed_action(author:)
track_unique_action(EPIC_LABELS, author)
end
private private
def track_unique_action(action, author) def track_unique_action(action, author)
......
...@@ -208,6 +208,16 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl ...@@ -208,6 +208,16 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'a daily tracked issuable event' do it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_ISSUE_ADDED } let(:action) { described_class::EPIC_ISSUE_ADDED }
end end
end
context 'for changing labels epic event' do
def track_action(params)
described_class.track_epic_labels_changed_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_LABELS }
end
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
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ResourceEvents::ChangeLabelsService do
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let_it_be(:labels) { create_list(:group_label, 2, group: group) }
let(:resource) { create(:epic, group: group) }
describe '.execute' do
subject { described_class.new(resource, user).execute(added_labels: added, removed_labels: removed) }
context 'when adding a label' do
let(:added) { [labels[0]] }
let(:removed) { [] }
it 'tracks the label change' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_labels_changed_action).with(author: user)
subject
end
end
context 'when removing a label' do
let(:added) { [] }
let(:removed) { [labels[1]] }
it 'tracks the label change' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_labels_changed_action).with(author: user)
subject
end
end
context 'when both adding and removing labels' do
let(:added) { [labels[0]] }
let(:removed) { [labels[1]] }
it 'tracks the label change' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_labels_changed_action).with(author: user)
subject
end
end
end
end
...@@ -220,19 +220,30 @@ RSpec.describe Epics::UpdateService do ...@@ -220,19 +220,30 @@ RSpec.describe Epics::UpdateService do
user: user2) user: user2)
end end
subject { update_epic(label_ids: [label.id]) }
before do before do
group.add_developer(user) group.add_developer(user)
update_epic(label_ids: [label.id])
end end
it 'marks todo as done for a user who added a label' do it 'marks todo as done for a user who added a label' do
subject
expect(todo1.reload.state).to eq('done') expect(todo1.reload.state).to eq('done')
end end
it 'does not mark todos as done for other users' do it 'does not mark todos as done for other users' do
subject
expect(todo2.reload.state).to eq('pending') expect(todo2.reload.state).to eq('pending')
end end
it 'tracks the label change' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_labels_changed_action).with(author: user)
subject
end
end end
context 'mentioning a group in epic description' do context 'mentioning a group in epic description' do
......
...@@ -122,3 +122,9 @@ ...@@ -122,3 +122,9 @@
redis_slot: project_management redis_slot: project_management
aggregation: daily aggregation: daily
feature_flag: track_epics_activity feature_flag: track_epics_activity
- name: g_project_management_epic_users_changing_labels
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
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