Commit e5da19af authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'epics-board-counter' into 'master'

Add redis counters for epic board actions [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!60357
parents 3be50b9f 42de7d2f
---
name: track_epic_boards_activity
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
rollout_issue_url:
milestone: '13.12'
type: development
group: group::product planning
default_enabled: true
......@@ -10234,6 +10234,78 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_creating_epic_boards_monthly`
Count of MAU creating epic boards
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210428072511_g_project_management_users_creating_epic_boards_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_creating_epic_boards_weekly`
Count of WAU creating epic boards
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210428072508_g_project_management_users_creating_epic_boards_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_updating_epic_board_names_monthly`
Count of MAU updating epic board names
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210428073607_g_project_management_users_updating_epic_board_names_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_updating_epic_board_names_weekly`
Count of WAU updating epic board names
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210428073604_g_project_management_users_updating_epic_board_names_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_viewing_epic_boards_monthly`
Count of MAU viewing epic boards
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210428073329_g_project_management_users_viewing_epic_boards_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epic_boards_usage.g_project_management_users_viewing_epic_boards_weekly`
Count of WAU viewing epic boards
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210428073327_g_project_management_users_viewing_epic_boards_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.epics_usage_total_unique_counts_monthly`
Total monthly users count for epics_usage
......
......@@ -2,6 +2,7 @@
class Groups::EpicBoardsController < Groups::ApplicationController
include BoardsActions
include RecordUserLastActivity
include RedisTracking
include Gitlab::Utils::StrongMemoize
extend ::Gitlab::Utils::Override
......@@ -11,6 +12,8 @@ class Groups::EpicBoardsController < Groups::ApplicationController
push_frontend_feature_flag(:boards_filtered_search, group)
end
track_redis_hll_event :index, :show, name: 'g_project_management_users_viewing_epic_boards'
feature_category :boards
private
......
......@@ -3,6 +3,7 @@
module Boards
module EpicBoards
class CreateService < Boards::CreateService
include Gitlab::Utils::UsageData
extend ::Gitlab::Utils::Override
override :can_create_board?
......@@ -14,6 +15,15 @@ module Boards
def parent_board_collection
parent.epic_boards
end
override :execute
def execute
super.tap do |response|
if response.success?
track_usage_event(:g_project_management_users_creating_epic_boards, current_user.id)
end
end
end
end
end
end
......@@ -3,8 +3,18 @@
module Boards
module EpicBoards
class UpdateService < Boards::UpdateService
include Gitlab::Utils::UsageData
extend ::Gitlab::Utils::Override
override :execute
def execute(board)
super.tap do
if board.saved_change_to_name?
track_usage_event(:g_project_management_users_updating_epic_board_names, current_user.id)
end
end
end
override :permitted_params
def permitted_params
permitted = PERMITTED_PARAMS
......
---
title: Track epic board user events (viewing, creating and updating titles).
merge_request: 60357
author:
type: added
---
# 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.epic_boards_usage.g_project_management_users_creating_epic_boards_monthly
description: Count of MAU creating epic boards
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
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.epic_boards_usage.g_project_management_users_viewing_epic_boards_monthly
description: Count of MAU viewing epic boards
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
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.epic_boards_usage.g_project_management_users_updating_epic_board_names_monthly
description: Count of MAU updating epic board names
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
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.epic_boards_usage.g_project_management_users_creating_epic_boards_weekly
description: Count of WAU creating epic boards
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_boards_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
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.epic_boards_usage.g_project_management_users_viewing_epic_boards_weekly
description: Count of WAU viewing epic boards
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_boards_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
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.epic_boards_usage.g_project_management_users_updating_epic_board_names_weekly
description: Count of WAU updating epic board names
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_boards_usage
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60357
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
......@@ -3,13 +3,10 @@
require 'spec_helper'
RSpec.describe Groups::EpicBoardsController do
let_it_be(:public_group) { create(:group, :public) }
let_it_be(:private_group) { create(:group, :private) }
let_it_be_with_reload(:group) { create(:group, :private) }
let_it_be(:user) { create(:user) }
let_it_be(:other_user) { create(:user) }
let(:group) { public_group }
before do
stub_licensed_features(epics: true)
......@@ -47,8 +44,6 @@ RSpec.describe Groups::EpicBoardsController do
end
context 'with unauthorized user' do
let_it_be(:group) { private_group }
before do
sign_in(other_user)
end
......@@ -77,6 +72,18 @@ RSpec.describe Groups::EpicBoardsController do
let(:parent) { group }
end
it_behaves_like 'tracking unique hll events' do
# make sure there is at least one board to list
# otherwise a new board would be created as part of
# index action and a different redis counter would be
# triggered first
let_it_be(:board) { create(:epic_board, group: group) }
subject(:request) { list_boards }
let(:target_id) { 'g_project_management_users_viewing_epic_boards' }
let(:expected_type) { instance_of(String) }
end
def list_boards(format: :html)
get :index, params: { group_id: group }, format: format
end
......@@ -116,8 +123,6 @@ RSpec.describe Groups::EpicBoardsController do
end
context 'with unauthorized user' do
let(:group) { private_group }
before do
# sign in some other user not in the private group
sign_in(other_user)
......@@ -131,10 +136,12 @@ RSpec.describe Groups::EpicBoardsController do
end
end
context 'when user is signed out' do
let(:group) { public_group }
context 'when group is public' do
before_all do
group.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
it 'does not save visit' do
it 'does not save visit for unsigned user' do
sign_out(user)
# epic board visits not supported yet
......@@ -159,6 +166,13 @@ RSpec.describe Groups::EpicBoardsController do
subject { read_board board: board }
end
it_behaves_like 'tracking unique hll events' do
subject(:request) { read_board(board: board) }
let(:target_id) { 'g_project_management_users_viewing_epic_boards' }
let(:expected_type) { instance_of(String) }
end
def read_board(board:, format: :html)
get :show, params: {
group_id: group,
......
......@@ -7,6 +7,8 @@ RSpec.describe Boards::EpicBoards::CreateService, services: true do
service.execute.payload
end
let_it_be(:user) { create(:user) }
let(:parent) { create(:group) }
let(:epic_boards_enabled) { false }
......@@ -16,7 +18,7 @@ RSpec.describe Boards::EpicBoards::CreateService, services: true do
context 'with epic boards feature not available' do
it 'does not create a board' do
service = described_class.new(parent, double)
service = described_class.new(parent, user)
expect(service.execute.payload).not_to be_nil
expect { service.execute }.not_to change(parent.epic_boards, :count)
......@@ -27,5 +29,12 @@ RSpec.describe Boards::EpicBoards::CreateService, services: true do
let(:epic_boards_enabled) { true }
it_behaves_like 'create a board', :epic_boards
it 'tracks epic board creation' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter)
.to receive(:track_event).with('g_project_management_users_creating_epic_boards', values: user.id)
described_class.new(parent, user).execute
end
end
end
......@@ -29,4 +29,11 @@ RSpec.describe Boards::EpicBoards::UpdateService, services: true do
end
it_behaves_like 'board update service'
it 'tracks epic board name updates' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter)
.to receive(:track_event).with('g_project_management_users_updating_epic_board_names', values: user.id)
described_class.new(group, user, name: 'foo').execute(board)
end
end
# frozen_string_literal: true
RSpec.shared_examples 'create a board' do |scope|
let_it_be(:user) { create(:user) }
context 'with valid params' do
subject(:service) { described_class.new(parent, double, name: 'Backend') }
subject(:service) { described_class.new(parent, user, name: 'Backend') }
it 'creates a new board' do
expect { service.execute }.to change(parent.send(scope), :count).by(1)
......@@ -22,7 +24,7 @@ RSpec.shared_examples 'create a board' do |scope|
end
context 'with invalid params' do
subject(:service) { described_class.new(parent, double, name: nil) }
subject(:service) { described_class.new(parent, user, name: nil) }
it 'does not create a new parent board' do
expect { service.execute }.not_to change(parent.send(scope), :count)
......@@ -38,7 +40,7 @@ RSpec.shared_examples 'create a board' do |scope|
end
context 'without params' do
subject(:service) { described_class.new(parent, double) }
subject(:service) { described_class.new(parent, user) }
it 'creates a new parent board' do
expect { service.execute }.to change(parent.send(scope), :count).by(1)
......
# Epic board 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_users_creating_epic_boards
category: epic_boards_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epic_boards_activity
- name: g_project_management_users_viewing_epic_boards
category: epic_boards_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epic_boards_activity
- name: g_project_management_users_updating_epic_board_names
category: epic_boards_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epic_boards_activity
......@@ -45,6 +45,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'quickactions',
'pipeline_authoring',
'epics_usage',
'epic_boards_usage',
'secure'
)
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