Commit 154c8c54 authored by Doug Stull's avatar Doug Stull

Merge branch 'issue_355471-count_related_epics_event_on_usage_data' into 'master'

Track related epics added on usage ping

See merge request gitlab-org/gitlab!83323
parents 1589c1db 113fa62f
......@@ -67,7 +67,9 @@ module IssuableLinks
target_issuables.map do |referenced_object|
link = relate_issuables(referenced_object)
unless link.valid?
if link.valid?
after_create_for(link)
else
@errors << _("%{ref} cannot be added: %{error}") % {
ref: referenced_object.to_reference,
error: link.errors.messages.values.flatten.to_sentence
......@@ -143,9 +145,17 @@ module IssuableLinks
# no-op
end
# Override on child classes to perform
# actions when the service is executed.
def track_event
# no-op
end
# Override on child classes to
# perform actions for each object created.
def after_create_for(_link)
# no-op
end
end
end
......
......@@ -14,6 +14,12 @@ module Epics::RelatedEpicLinks
private
def after_create_for(link)
if link.link_type == link.class::TYPE_RELATES_TO
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_related_added(author: current_user)
end
end
def references(extractor)
extractor.epics
end
......
......@@ -44,6 +44,7 @@ options:
- g_project_management_epic_destroyed
- g_project_management_epic_cross_referenced
- g_project_management_users_epic_issue_added_from_epic
- g_project_management_epic_related_added
distribution:
- ee
tier:
......
---
key_path: redis_hll_counters.epics_usage.g_project_management_epic_related_added_monthly
description: Count of MAU adding related epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: active
milestone: "14.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83323
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- g_project_management_epic_related_added
distribution:
- ee
tier:
- ultimate
......@@ -44,6 +44,7 @@ options:
- g_project_management_epic_destroyed
- g_project_management_epic_cross_referenced
- g_project_management_users_epic_issue_added_from_epic
- g_project_management_epic_related_added
distribution:
- ee
tier:
......
---
key_path: redis_hll_counters.epics_usage.g_project_management_epic_related_added_weekly
description: Count of WAU adding related epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: active
milestone: "14.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83323
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- g_project_management_epic_related_added
distribution:
- ee
tier:
- ultimate
......@@ -35,6 +35,7 @@ module Gitlab
EPIC_TASK_CHECKED = 'project_management_users_checking_epic_task'
EPIC_TASK_UNCHECKED = 'project_management_users_unchecking_epic_task'
EPIC_CROSS_REFERENCED = 'g_project_management_epic_cross_referenced'
EPIC_RELATED_ADDED = 'g_project_management_epic_related_added'
class << self
def track_epic_created_action(author:)
......@@ -149,6 +150,10 @@ module Gitlab
track_unique_action(EPIC_CROSS_REFERENCED, author)
end
def track_epic_related_added(author:)
track_unique_action(EPIC_RELATED_ADDED, author)
end
private
def track_unique_action(action, author)
......
......@@ -337,4 +337,16 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for related epic added' do
def track_action(params)
described_class.track_epic_related_added(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_RELATED_ADDED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
end
......@@ -52,5 +52,20 @@ RSpec.describe Epics::RelatedEpicLinks::CreateService do
expect(issuable_link_class.find_by!(target: issuable3)).to have_attributes(source: issuable, link_type: 'relates_to')
end
end
context 'event tracking' do
context 'for related link type' do
it 'records event for each link created' do
params = {
link_type: IssuableLink::TYPE_RELATES_TO,
issuable_references: [issuable_a, issuable3].map { |epic| epic.to_reference(issuable.group, full: true) }
}
expect(Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_related_added).with(author: user).twice
described_class.new(issuable, user, params).execute
end
end
end
end
end
......@@ -188,3 +188,9 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_epic_related_added
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