Commit ca786904 authored by Felipe Artur's avatar Felipe Artur

Track epics created

Add epics created to usaged ping using
redis counter
parent 0f0fabbf
......@@ -6368,6 +6368,30 @@ Status: `data_available`
Tiers: `free`
### `g_project_management_epic_created_monthly`
Count of MAU creating epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210305144719_g_product_planning_epic_created_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `g_project_management_epic_created_weekly`
Count of WAU creating epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210305145820_g_product_planning_epic_created_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `geo_enabled`
Is Geo enabled?
......
......@@ -135,6 +135,7 @@ module EE
before_save :set_fixed_start_date, if: :start_date_is_fixed?
before_save :set_fixed_due_date, if: :due_date_is_fixed?
after_create_commit :usage_ping_record_epic_creation
def epic_tree_root?
parent_id.nil?
......@@ -161,6 +162,10 @@ module EE
self.due_date_sourcing_milestone = nil
self.due_date_sourcing_epic = nil
end
def usage_ping_record_epic_creation
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_created_action(author: author)
end
end
class_methods do
......
---
title: Track epic creation action on usage ping
merge_request: 53651
author:
type: other
---
name: track_epics_activity
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53651
rollout_issue_url:
milestone: '13.10'
type: development
group: group::product planning
default_enabled: true
---
# 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: g_project_management_epic_created_monthly
description: Count of MAU creating epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53651
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: g_project_management_epic_created_weekly
description: Count of WAU creating epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53651
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
module EpicActivityUniqueCounter
# The 'g_project_management' prefix need to be present
# on epic event names, because they are persisted at the same
# 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'
class << self
def track_epic_created_action(author:, time: Time.zone.now)
track_unique_action(EPIC_CREATED, author, time)
end
private
def track_unique_action(action, author, time)
return unless Feature.enabled?(:track_epics_activity, default_enabled: true)
return unless author
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id, time: time)
end
end
end
end
end
......@@ -9,7 +9,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
let(:time) { Time.zone.now }
context 'for Issue health status changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_HEALTH_STATUS_CHANGED }
def track_action(params)
......@@ -19,7 +19,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue iteration changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_ITERATION_CHANGED }
def track_action(params)
......@@ -29,7 +29,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue weight changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_WEIGHT_CHANGED }
def track_action(params)
......@@ -39,7 +39,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue added to epic actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_ADDED_TO_EPIC}
def track_action(params)
......@@ -49,7 +49,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue removed from epic actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_REMOVED_FROM_EPIC}
def track_action(params)
......@@ -59,7 +59,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue changed epic actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CHANGED_EPIC}
def track_action(params)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitlab_redis_shared_state do
let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) }
let(:time) { Time.zone.now }
context 'for epic created event' do
def track_action(params)
described_class.track_epic_created_action(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_CREATED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
end
......@@ -725,4 +725,12 @@ RSpec.describe Epic do
end
it_behaves_like 'versioned description'
describe '#usage_ping_record_epic_creation' do
it 'records epic creation after saving' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_created_action)
create(:epic)
end
end
end
......@@ -445,3 +445,13 @@
redis_slot: pipeline_authoring
aggregation: weekly
feature_flag: usage_data_o_pipeline_authoring_unique_users_pushing_mr_ciconfigfile
# Epic events
#
# We are using the same slot of issue events 'project_management' for
# epic events to allow data aggregation.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/322405
- name: g_project_management_epic_created
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
......@@ -42,7 +42,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'terraform',
'ci_templates',
'quickactions',
'pipeline_authoring'
'pipeline_authoring',
'epics_usage'
)
end
end
......
......@@ -9,7 +9,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
let(:time) { Time.zone.now }
context 'for Issue title edit actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_TITLE_CHANGED }
def track_action(params)
......@@ -19,7 +19,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue description edit actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_DESCRIPTION_CHANGED }
def track_action(params)
......@@ -29,7 +29,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue assignee edit actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_ASSIGNEE_CHANGED }
def track_action(params)
......@@ -39,7 +39,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue make confidential actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_MADE_CONFIDENTIAL }
def track_action(params)
......@@ -49,7 +49,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue make visible actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_MADE_VISIBLE }
def track_action(params)
......@@ -59,7 +59,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue created actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CREATED }
def track_action(params)
......@@ -69,7 +69,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue closed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CLOSED }
def track_action(params)
......@@ -79,7 +79,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue reopened actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_REOPENED }
def track_action(params)
......@@ -89,7 +89,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue label changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_LABEL_CHANGED }
def track_action(params)
......@@ -99,7 +99,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue cross-referenced actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CROSS_REFERENCED }
def track_action(params)
......@@ -109,7 +109,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue moved actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_MOVED }
def track_action(params)
......@@ -119,7 +119,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue cloned actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CLONED }
def track_action(params)
......@@ -129,7 +129,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue relate actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_RELATED }
def track_action(params)
......@@ -139,7 +139,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue unrelate actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_UNRELATED }
def track_action(params)
......@@ -149,7 +149,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue marked as duplicate actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_MARKED_AS_DUPLICATE }
def track_action(params)
......@@ -159,7 +159,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue locked actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_LOCKED }
def track_action(params)
......@@ -169,7 +169,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue unlocked actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_UNLOCKED }
def track_action(params)
......@@ -179,7 +179,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue designs added actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_DESIGNS_ADDED }
def track_action(params)
......@@ -189,7 +189,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue designs modified actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_DESIGNS_MODIFIED }
def track_action(params)
......@@ -199,7 +199,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue designs removed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_DESIGNS_REMOVED }
def track_action(params)
......@@ -209,7 +209,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue due date changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_DUE_DATE_CHANGED }
def track_action(params)
......@@ -219,7 +219,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue time estimate changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_TIME_ESTIMATE_CHANGED }
def track_action(params)
......@@ -229,7 +229,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue time spent changed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_TIME_SPENT_CHANGED }
def track_action(params)
......@@ -239,7 +239,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue comment added actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_COMMENT_ADDED }
def track_action(params)
......@@ -249,7 +249,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue comment edited actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_COMMENT_EDITED }
def track_action(params)
......@@ -259,7 +259,7 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue comment removed actions' do
it_behaves_like 'a tracked issue edit event' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_COMMENT_REMOVED }
def track_action(params)
......
......@@ -1353,7 +1353,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let(:categories) { ::Gitlab::UsageDataCounters::HLLRedisCounter.categories }
let(:ineligible_total_categories) do
%w[source_code ci_secrets_management incident_management_alerts snippets terraform]
%w[source_code ci_secrets_management incident_management_alerts snippets terraform epics_usage]
end
it 'has all known_events' do
......
# frozen_string_literal: true
RSpec.shared_examples 'a tracked issue edit event' do |event|
RSpec.shared_examples 'a daily tracked issuable event' do
before do
stub_application_setting(usage_ping_enabled: true)
end
......@@ -25,3 +25,13 @@ RSpec.shared_examples 'a tracked issue edit event' do |event|
expect(track_action(author: nil)).to be_nil
end
end
RSpec.shared_examples 'does not track when feature flag is disabled' do |feature_flag|
context "when feature flag #{feature_flag} is disabled" do
it 'does not track action' do
stub_feature_flags(feature_flag => false)
expect(track_action(author: user1)).to be_nil
end
end
end
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