Commit 4381c717 authored by Felipe Artur's avatar Felipe Artur

Track epic cross reference on usage ping

Record epic cross reference event
parent cf5e9f0f
......@@ -178,8 +178,7 @@ module SystemNotes
if noteable.is_a?(ExternalIssue)
noteable.project.external_issue_tracker.create_cross_reference_note(noteable, mentioner, author)
else
issue_activity_counter.track_issue_cross_referenced_action(author: author) if noteable.is_a?(Issue)
track_cross_reference_action
create_note(NoteSummary.new(noteable, noteable.project, author, body, action: 'cross_reference'))
end
end
......@@ -414,6 +413,10 @@ module SystemNotes
def issue_activity_counter
Gitlab::UsageDataCounters::IssueActivityUniqueCounter
end
def track_cross_reference_action
issue_activity_counter.track_issue_cross_referenced_action(author: author) if noteable.is_a?(Issue)
end
end
end
......
......@@ -10292,6 +10292,30 @@ Status: `data_available`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_cross_referenced_monthly`
Count of MAU cross referencing epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210430174100_g_project_management_epic_cross_referenced_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_cross_referenced_weekly`
Counts of WAU cross referencing epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210430173650_g_project_management_epic_cross_referenced_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_destroyed_monthly`
Count of MAU destroying epics
......
......@@ -2,6 +2,7 @@
module EE
module SystemNotes
module IssuablesService
extend ::Gitlab::Utils::Override
# Called when the health_status of an Issue is changed
#
# Example Note text:
......@@ -33,6 +34,15 @@ module EE
create_note(NoteSummary.new(noteable, project, author, body, action: 'published'))
end
override :track_cross_reference_action
def track_cross_reference_action
super
counter = ::Gitlab::UsageDataCounters::EpicActivityUniqueCounter
counter.track_epic_cross_referenced(author: author) if noteable.is_a?(Epic)
end
end
end
end
---
title: Track epic cross reference on usage ping
merge_request: 59804
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_cross_referenced_monthly
description: Count of MAU cross referencing epics
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/59804
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_cross_referenced_weekly
description: Counts of WAU cross referencing epics
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/59804
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
......@@ -32,6 +32,7 @@ module Gitlab
EPIC_DESTROYED = 'g_project_management_epic_destroyed'
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'
class << self
def track_epic_created_action(author:)
......@@ -134,6 +135,10 @@ module Gitlab
track_unique_action(EPIC_TASK_UNCHECKED, author)
end
def track_epic_cross_referenced(author:)
track_unique_action(EPIC_CROSS_REFERENCED, author)
end
private
def track_unique_action(action, author)
......
......@@ -303,4 +303,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 epic cross reference' do
def track_action(params)
described_class.track_epic_cross_referenced(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_CROSS_REFERENCED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
end
......@@ -60,4 +60,32 @@ RSpec.describe ::SystemNotes::IssuablesService do
expect(subject.note).to eq 'published this issue to the status page'
end
end
describe '#cross_reference' do
let(:mentioner) { create(:issue, project: project) }
subject { service.cross_reference(mentioner) }
context 'when noteable is an epic' do
let(:noteable) { epic }
it_behaves_like 'a system note', exclude_project: true do
let(:action) { 'cross_reference' }
end
it 'tracks epic cross reference event in usage ping' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_cross_referenced).with(author: author)
subject
end
end
context 'when notable is not an epic' do
it 'does not tracks epic cross reference event in usage ping' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).not_to receive(:track_epic_cross_referenced)
subject
end
end
end
end
......@@ -162,3 +162,9 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_epic_cross_referenced
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