Commit 7a10b532 authored by Felipe Artur's avatar Felipe Artur

Track issues removed from epics on usage ping

Track issues removed from epics
on usage ping using Redis HLL.
parent 67e9e9ab
...@@ -15,14 +15,18 @@ module IssuableLinks ...@@ -15,14 +15,18 @@ module IssuableLinks
return error(not_found_message, 404) unless permission_to_remove_relation? return error(not_found_message, 404) unless permission_to_remove_relation?
remove_relation remove_relation
create_notes after_destroy
track_event
success(message: 'Relation was removed') success(message: 'Relation was removed')
end end
private private
def after_destroy
create_notes
track_event
end
def remove_relation def remove_relation
link.destroy! link.destroy!
end end
......
...@@ -9908,6 +9908,30 @@ Status: `implemented` ...@@ -9908,6 +9908,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate` Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_monthly`
Count of MAU removing issues from epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210401183230_g_project_management_epic_issue_removed_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_weekly`
Counts of WAU removing issues from epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210401182457_g_project_management_g_project_management_epic_issue_removed_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_reopened_monthly` ### `redis_hll_counters.epics_usage.g_project_management_epic_reopened_monthly`
Counts of MAU closing epics Counts of MAU closing epics
......
...@@ -2,14 +2,21 @@ ...@@ -2,14 +2,21 @@
module EpicIssues module EpicIssues
class DestroyService < IssuableLinks::DestroyService class DestroyService < IssuableLinks::DestroyService
def execute extend ::Gitlab::Utils::Override
result = super
Epics::UpdateDatesService.new([link.epic]).execute private
override :after_destroy
def after_destroy
super
result Epics::UpdateDatesService.new([link.epic]).execute
track_usage_ping_event
end end
private def track_usage_ping_event
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_issue_removed(author: current_user)
end
def source def source
@source ||= link.epic @source ||= link.epic
......
---
title: Track issue removed from epic on usage ping
merge_request: 58426
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_issue_removed_monthly
description: Count of MAU removing issues from epics
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/58426
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_issue_removed_weekly
description: Counts of WAU removing issues from epics
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/58426
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
...@@ -20,6 +20,7 @@ module Gitlab ...@@ -20,6 +20,7 @@ module Gitlab
EPIC_FIXED_START_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_start_date' EPIC_FIXED_START_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_start_date'
EPIC_FIXED_DUE_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_due_date' EPIC_FIXED_DUE_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_due_date'
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_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'
...@@ -77,6 +78,10 @@ module Gitlab ...@@ -77,6 +78,10 @@ module Gitlab
track_unique_action(EPIC_ISSUE_ADDED, author) track_unique_action(EPIC_ISSUE_ADDED, author)
end end
def track_epic_issue_removed(author:)
track_unique_action(EPIC_ISSUE_REMOVED, 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
......
...@@ -188,6 +188,18 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl ...@@ -188,6 +188,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 'for removing issue from epic event' do
def track_action(params)
described_class.track_epic_issue_removed(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_ISSUE_REMOVED }
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)
......
...@@ -66,6 +66,13 @@ RSpec.describe EpicIssues::DestroyService do ...@@ -66,6 +66,13 @@ RSpec.describe EpicIssues::DestroyService do
expect(note.noteable_type).to eq('Issue') expect(note.noteable_type).to eq('Issue')
expect(note.system_note_metadata.action).to eq('issue_removed_from_epic') expect(note.system_note_metadata.action).to eq('issue_removed_from_epic')
end end
it 'counts an usage ping event' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_issue_removed)
.with(author: user)
subject
end
end end
context 'user does not have permissions to remove associations' do context 'user does not have permissions to remove associations' do
...@@ -76,10 +83,18 @@ RSpec.describe EpicIssues::DestroyService do ...@@ -76,10 +83,18 @@ RSpec.describe EpicIssues::DestroyService do
it 'returns error message' do it 'returns error message' do
is_expected.to eq(message: 'No Issue Link found', status: :error, http_status: 404) is_expected.to eq(message: 'No Issue Link found', status: :error, http_status: 404)
end end
it 'does not counts an usage ping event' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).not_to receive(:track_epic_issue_removed)
subject
end
end end
context 'refresh epic dates' do context 'refresh epic dates' do
it 'calls UpdateDatesService' do it 'calls UpdateDatesService' do
group.add_reporter(user)
expect(Epics::UpdateDatesService).to receive(:new).with([epic_issue.epic]).and_call_original expect(Epics::UpdateDatesService).to receive(:new).with([epic_issue.epic]).and_call_original
subject subject
......
...@@ -87,6 +87,12 @@ ...@@ -87,6 +87,12 @@
aggregation: daily aggregation: daily
feature_flag: track_epics_activity feature_flag: track_epics_activity
- name: g_project_management_epic_issue_removed
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