Commit aa259ef5 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch '292253-cablett-track-epic-start-date-fixed' into 'master'

Track epic set start date as fixed or inherited via usage ping

See merge request gitlab-org/gitlab!56619
parents cd33b34e cc6000a7
......@@ -9836,6 +9836,54 @@ Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_fixed_monthly`
Counts of MAU setting epic start date as fixed
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210315055624_g_project_management_users_setting_epic_start_date_as_fixed_monthly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_fixed_weekly`
Counts of WAU setting epic start date as fixed
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210315054905_g_project_management_users_setting_epic_start_date_as_fixed_weekly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_inherited_monthly`
Counts of MAU setting epic start date as inherited
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210315055439_g_project_management_users_setting_epic_start_date_as_inherited_monthly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_inherited_weekly`
Counts of WAU setting epic start date as inherited
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210315055342_g_project_management_users_setting_epic_start_date_as_inherited_weekly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.ide_edit.g_edit_by_sfe_monthly`
Missing description
......
......@@ -18,6 +18,9 @@ module Epics
if saved_change_to_epic_dates?(epic)
Epics::UpdateDatesService.new([epic]).execute
track_start_date_fixed_events(epic)
epic.reset
end
......@@ -51,6 +54,16 @@ module Epics
private
def track_start_date_fixed_events(epic)
return unless epic.saved_changes.key?('start_date_is_fixed')
if epic.start_date_is_fixed?
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_start_date_set_as_fixed_action(author: current_user)
else
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_start_date_set_as_inherited_action(author: current_user)
end
end
def saved_change_to_epic_dates?(epic)
(epic.saved_changes.keys.map(&:to_sym) & EPIC_DATE_FIELDS).present?
end
......
---
title: Track epic start date set to fixed or inherited via usage ping
merge_request: 56619
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_start_date_as_inherited_monthly
description: Counts of MAU setting epic start date as inherited
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/56619
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_start_date_as_fixed_monthly
description: Counts of MAU setting epic start date as fixed
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/56619
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_start_date_as_fixed_weekly
description: Counts of WAU setting epic start date as fixed
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/56619
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_start_date_as_inherited_weekly
description: Counts of WAU setting epic start date as inherited
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/56619
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
......@@ -8,6 +8,8 @@ module Gitlab
# slot of issue events to allow data aggregation.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/322405
EPIC_CREATED = 'g_project_management_epic_created'
EPIC_START_DATE_SET_AS_FIXED = 'g_project_management_users_setting_epic_start_date_as_fixed'
EPIC_START_DATE_SET_AS_INHERITED = 'g_project_management_users_setting_epic_start_date_as_inherited'
EPIC_NOTE_DESTROYED = 'g_project_management_users_destroying_epic_notes'
class << self
......@@ -19,6 +21,14 @@ module Gitlab
track_unique_action(EPIC_NOTE_DESTROYED, author, time)
end
def track_epic_start_date_set_as_fixed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_START_DATE_SET_AS_FIXED, author, time)
end
def track_epic_start_date_set_as_inherited_action(author:, time: Time.zone.now)
track_unique_action(EPIC_START_DATE_SET_AS_INHERITED, author, time)
end
private
def track_unique_action(action, author, time)
......
......@@ -31,4 +31,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 epic date modification events' do
context 'setting start date as fixed event' do
def track_action(params)
described_class.track_epic_start_date_set_as_fixed_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_START_DATE_SET_AS_FIXED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'setting start date as inherited event' do
def track_action(params)
described_class.track_epic_start_date_set_as_inherited_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_START_DATE_SET_AS_INHERITED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
end
end
......@@ -293,6 +293,20 @@ RSpec.describe Epics::UpdateService do
end
end
context 'epic start date fixed or inherited' do
it 'tracks the user action to set as fixed' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_start_date_set_as_fixed_action)
update_epic(start_date_is_fixed: true, start_date_fixed: Date.today)
end
it 'tracks the user action to set as inherited' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_start_date_set_as_inherited_action)
update_epic(start_date_is_fixed: false)
end
end
context 'date fields are not updated' do
it 'does not call UpdateDatesService' do
expect(Epics::UpdateDatesService).not_to receive(:new)
......
......@@ -14,3 +14,15 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_start_date_as_fixed
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_start_date_as_inherited
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