diff --git a/doc/development/usage_ping/dictionary.md b/doc/development/usage_ping/dictionary.md index 9370baf0ac991f3361cfe2d2a3bf3fbca82331d1..2ce3a8be04c7aed63fa4fb4671229ea75eed913d 100644 --- a/doc/development/usage_ping/dictionary.md +++ b/doc/development/usage_ping/dictionary.md @@ -9884,6 +9884,30 @@ Status: `implemented` Tiers: `premium`, `ultimate` +### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_notes_monthly` + +Counts of MAU updating epic notes + +[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210314234202_g_project_management_users_updating_epic_notes_monthly.yml) + +Group: `group:product planning` + +Status: `implemented` + +Tiers: `premium`, `ultimate` + +### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_notes_weekly` + +Counts of WAU updating epic notes + +[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210314234041_g_project_management_users_updating_epic_notes_weekly.yml) + +Group: `group:product planning` + +Status: `implemented` + +Tiers: `premium`, `ultimate` + ### `redis_hll_counters.ide_edit.g_edit_by_sfe_monthly` Missing description diff --git a/ee/app/models/ee/note.rb b/ee/app/models/ee/note.rb index 378849df82db3658593f302f0fcf68496d655249..974eb399d3b493d2b6a461f5e491025091566713 100644 --- a/ee/app/models/ee/note.rb +++ b/ee/app/models/ee/note.rb @@ -76,6 +76,10 @@ module EE for_vulnerability? || super end + def usage_ping_track_updated_epic_note(user) + ::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_note_updated_action(author: user) if for_epic? + end + private def system_note_for_epic? diff --git a/ee/app/services/ee/notes/update_service.rb b/ee/app/services/ee/notes/update_service.rb index b7f068dca22fab9b8bdf93ea3e3483e897bbf3b6..ce1c68663e6d8ae7acc97fbce3f24b5f5a51129d 100644 --- a/ee/app/services/ee/notes/update_service.rb +++ b/ee/app/services/ee/notes/update_service.rb @@ -13,6 +13,8 @@ module EE ::Gitlab::StatusPage.trigger_publish(project, current_user, updated_note) end + note.usage_ping_track_updated_epic_note(current_user) if note.for_epic? + updated_note end end diff --git a/ee/changelogs/unreleased/292253-cablett-update-epic-note.yml b/ee/changelogs/unreleased/292253-cablett-update-epic-note.yml new file mode 100644 index 0000000000000000000000000000000000000000..21b63c46150e5f9b17b09a583d7cc6548f76f8ed --- /dev/null +++ b/ee/changelogs/unreleased/292253-cablett-update-epic-note.yml @@ -0,0 +1,5 @@ +--- +title: Track epic comment updated +merge_request: 56610 +author: +type: other diff --git a/ee/config/metrics/counts_28d/20210314234202_g_project_management_users_updating_epic_notes_monthly.yml b/ee/config/metrics/counts_28d/20210314234202_g_project_management_users_updating_epic_notes_monthly.yml new file mode 100644 index 0000000000000000000000000000000000000000..c68d748cc1735b85eb24f90f0461c3579a0e5edf --- /dev/null +++ b/ee/config/metrics/counts_28d/20210314234202_g_project_management_users_updating_epic_notes_monthly.yml @@ -0,0 +1,21 @@ +--- +# 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_updating_epic_notes_monthly +description: Counts of MAU updating epic notes +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/56610 +time_frame: 28d +data_source: redis_hll +distribution: +- ee +tier: +- premium +- ultimate diff --git a/ee/config/metrics/counts_7d/20210314234041_g_project_management_users_updating_epic_notes_weekly.yml b/ee/config/metrics/counts_7d/20210314234041_g_project_management_users_updating_epic_notes_weekly.yml new file mode 100644 index 0000000000000000000000000000000000000000..be623af48a61e39dd8fd5986919ca0c3a6348ca4 --- /dev/null +++ b/ee/config/metrics/counts_7d/20210314234041_g_project_management_users_updating_epic_notes_weekly.yml @@ -0,0 +1,21 @@ +--- +# 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_updating_epic_notes_weekly +description: Counts of WAU updating epic notes +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/56610 +time_frame: 7d +data_source: redis_hll +distribution: +- ee +tier: +- premium +- ultimate diff --git a/ee/lib/gitlab/usage_data_counters/epic_activity_unique_counter.rb b/ee/lib/gitlab/usage_data_counters/epic_activity_unique_counter.rb index 0d45a2b8202a8bd22ae03495c40f8b28190e68ed..ee1c02edcdb09820eabbd8033b9e3085c979603e 100644 --- a/ee/lib/gitlab/usage_data_counters/epic_activity_unique_counter.rb +++ b/ee/lib/gitlab/usage_data_counters/epic_activity_unique_counter.rb @@ -8,15 +8,20 @@ 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_NOTE_UPDATED = 'g_project_management_users_updating_epic_notes' + EPIC_NOTE_DESTROYED = 'g_project_management_users_destroying_epic_notes' 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 def track_epic_created_action(author:, time: Time.zone.now) track_unique_action(EPIC_CREATED, author, time) end + def track_epic_note_updated_action(author:, time: Time.zone.now) + track_unique_action(EPIC_NOTE_UPDATED, author, time) + end + def track_epic_note_destroyed_action(author:, time: Time.zone.now) track_unique_action(EPIC_NOTE_DESTROYED, author, time) end diff --git a/ee/spec/lib/gitlab/usage_data_counters/epic_activity_unique_counter_spec.rb b/ee/spec/lib/gitlab/usage_data_counters/epic_activity_unique_counter_spec.rb index c2287aa47e4ace7681e965af16e961a2fbd004ff..2d9ac5223e92f6f603f52d981103922b3e9ab2ce 100644 --- a/ee/spec/lib/gitlab/usage_data_counters/epic_activity_unique_counter_spec.rb +++ b/ee/spec/lib/gitlab/usage_data_counters/epic_activity_unique_counter_spec.rb @@ -20,6 +20,18 @@ 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 note updated event' do + def track_action(params) + described_class.track_epic_note_updated_action(**params) + end + + it_behaves_like 'a daily tracked issuable event' do + let(:action) { described_class::EPIC_NOTE_UPDATED } + end + + it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity + end + context 'for epic note destroyed event' do def track_action(params) described_class.track_epic_note_destroyed_action(**params) diff --git a/ee/spec/services/ee/notes/update_service_spec.rb b/ee/spec/services/ee/notes/update_service_spec.rb index 34d208392d92d9712b21741aab361c5ef434c1b2..7a614f723b19a6ad291d8685eeff28382f9f1167 100644 --- a/ee/spec/services/ee/notes/update_service_spec.rb +++ b/ee/spec/services/ee/notes/update_service_spec.rb @@ -10,11 +10,12 @@ RSpec.describe Notes::UpdateService do create(:note_on_issue, project: project, author: user) end + let(:note_text) { 'text' } + let(:opts) { { note: note_text } } + subject(:service) { described_class.new(project, user, opts) } describe '#execute' do - let(:opts) { { note: note_text } } - describe 'publish to status page' do let(:execute) { service.execute(note) } let(:issue_id) { note.noteable_id } @@ -25,8 +26,6 @@ RSpec.describe Notes::UpdateService do end context 'for text-only update' do - let(:note_text) { 'text' } - include_examples 'trigger status page publish' context 'without recognized emoji' do @@ -49,4 +48,17 @@ RSpec.describe Notes::UpdateService do end end end + + context 'for epics' do + let_it_be(:epic) { create(:epic) } + let_it_be(:note) { create(:note, noteable: epic) } + + subject(:service) { described_class.new(nil, user, opts) } + + it 'tracks epic note creation' do + expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_note_updated_action).with(author: user) + + described_class.new(nil, user, opts).execute(note) + end + end end diff --git a/lib/gitlab/usage_data_counters/known_events/epic_events.yml b/lib/gitlab/usage_data_counters/known_events/epic_events.yml index 45ff5086c785fceca021b73e423330782909df76..7cd2a72d8caf38466c9b51f420911ab3c8243818 100644 --- a/lib/gitlab/usage_data_counters/known_events/epic_events.yml +++ b/lib/gitlab/usage_data_counters/known_events/epic_events.yml @@ -9,6 +9,12 @@ aggregation: daily feature_flag: track_epics_activity +- name: g_project_management_users_updating_epic_notes + category: epics_usage + redis_slot: project_management + aggregation: daily + feature_flag: track_epics_activity + - name: g_project_management_users_destroying_epic_notes category: epics_usage redis_slot: project_management