Commit 159ecc10 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

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

Track making epics confidential/visible

See merge request gitlab-org/gitlab!56483
parents fca7eab7 5f3af62b
......@@ -10004,6 +10004,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_confidential_monthly`
Count of MAU making epics confidential
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210310203049_g_project_management_epic_confidential_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_confidential_weekly`
Count of WAU making epics confidential
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210310203225_g_project_management_epic_confidential_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_due_date_as_fixed_monthly`
Counts of MAU setting epic due date as inherited
......@@ -10100,6 +10124,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_visible_monthly`
Count of MAU making epics visible
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210312093611_g_project_management_epic_visible_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_visible_weekly`
Count of WAU making epics visible
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210312093243_g_poject_management_epic_visible_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_descriptions_monthly`
Counts of MAU changing epic descriptions
......
......@@ -47,9 +47,18 @@ module Epics
todo_service.update_epic(epic, current_user, old_mentioned_users)
if epic.previous_changes.include?('confidential') && epic.confidential?
if epic.saved_change_to_attribute?(:confidential)
handle_confidentiality_change(epic)
end
end
def handle_confidentiality_change(epic)
if epic.confidential?
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_confidential_action(author: current_user)
# don't enqueue immediately to prevent todos removal in case of a mistake
::TodosDestroyer::ConfidentialEpicWorker.perform_in(::Todo::WAIT_FOR_DELETE, epic.id)
else
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_visible_action(author: current_user)
end
end
......
---
title: Track epic confidentiality change action on usage ping
merge_request: 56483
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_setting_epic_confidential_monthly
description: Count of MAU making epics confidential
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/56246
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_setting_epic_visible_monthly
description: Count of MAU making epics visible
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/56246
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_setting_epic_confidential_weekly
description: Count of WAU making epics confidential
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/56246
time_frame: 7d
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_setting_epic_visible_weekly
description: Count of WAU making epics visible
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/56246
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
......@@ -23,6 +23,8 @@ module Gitlab
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'
EPIC_CONFIDENTIAL = 'g_project_management_users_setting_epic_confidential'
EPIC_VISIBLE = 'g_project_management_users_setting_epic_visible'
class << self
def track_epic_created_action(author:)
......@@ -89,6 +91,14 @@ module Gitlab
track_unique_action(ISSUE_PROMOTED_TO_EPIC, author)
end
def track_epic_confidential_action(author:)
track_unique_action(EPIC_CONFIDENTIAL, author)
end
def track_epic_visible_action(author:)
track_unique_action(EPIC_VISIBLE, author)
end
private
def track_unique_action(action, author)
......
......@@ -98,6 +98,30 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for making epic visible' do
def track_action(params)
described_class.track_epic_visible_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_VISIBLE }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for making epic confidential' do
def track_action(params)
described_class.track_epic_confidential_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_CONFIDENTIAL }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for epic date modification events' do
context 'start date' do
context 'setting as fixed event' do
......
......@@ -269,10 +269,38 @@ RSpec.describe Epics::UpdateService do
end
end
it 'schedules deletion of todos when epic becomes confidential' do
expect(TodosDestroyer::ConfidentialEpicWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, epic.id)
context 'when the epic becomes confidential' do
it 'schedules deletion of todos' do
expect(TodosDestroyer::ConfidentialEpicWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, epic.id)
update_epic(confidential: true)
update_epic(confidential: true)
end
it 'tracks the epic becoming confidential' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_confidential_action).with(author: user)
update_epic(confidential: true)
end
end
context 'when the epic becomes visible' do
before do
epic.update_column(:confidential, true)
end
it 'does not schedule deletion of todos' do
expect(TodosDestroyer::ConfidentialEpicWorker).not_to receive(:perform_in)
update_epic(confidential: false)
end
it 'tracks the epic becoming visible' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter)
.to receive(:track_epic_visible_action).with(author: user)
update_epic(confidential: false)
end
end
end
......
......@@ -104,3 +104,15 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_confidential
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_visible
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