Commit ab785876 authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz

Add merge request analytics to usage ping

Track uniques visits to merge request analytics
pages on both project and group level
parent 2e28862e
# frozen_string_literal: true # frozen_string_literal: true
class Groups::Analytics::MergeRequestAnalyticsController < Groups::Analytics::ApplicationController class Groups::Analytics::MergeRequestAnalyticsController < Groups::Analytics::ApplicationController
include Analytics::UniqueVisitsHelper
check_feature_flag Gitlab::Analytics::GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG check_feature_flag Gitlab::Analytics::GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG
layout 'group' layout 'group'
...@@ -13,6 +15,8 @@ class Groups::Analytics::MergeRequestAnalyticsController < Groups::Analytics::Ap ...@@ -13,6 +15,8 @@ class Groups::Analytics::MergeRequestAnalyticsController < Groups::Analytics::Ap
authorize_view_by_action!(:read_group_merge_request_analytics) authorize_view_by_action!(:read_group_merge_request_analytics)
} }
track_unique_visits :show, target_id: 'g_analytics_merge_request'
def show def show
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
class Projects::Analytics::MergeRequestAnalyticsController < Projects::ApplicationController class Projects::Analytics::MergeRequestAnalyticsController < Projects::ApplicationController
include Analytics::UniqueVisitsHelper
before_action :authorize_read_project_merge_request_analytics! before_action :authorize_read_project_merge_request_analytics!
track_unique_visits :show, target_id: 'p_analytics_merge_request'
def show def show
end end
end end
...@@ -15,7 +15,7 @@ RSpec.describe Groups::Analytics::MergeRequestAnalyticsController do ...@@ -15,7 +15,7 @@ RSpec.describe Groups::Analytics::MergeRequestAnalyticsController do
stub_licensed_features(feature_name => true) stub_licensed_features(feature_name => true)
end end
describe 'GET show' do describe 'GET #show' do
subject { get :show, params: { group_id: group } } subject { get :show, params: { group_id: group } }
before do before do
...@@ -24,6 +24,11 @@ RSpec.describe Groups::Analytics::MergeRequestAnalyticsController do ...@@ -24,6 +24,11 @@ RSpec.describe Groups::Analytics::MergeRequestAnalyticsController do
it { is_expected.to be_successful } it { is_expected.to be_successful }
it_behaves_like 'tracking unique visits', :show do
let(:request_params) { { group_id: group } }
let(:target_id) { 'g_analytics_merge_request' }
end
context 'when license is missing' do context 'when license is missing' do
before do before do
stub_licensed_features(feature_name => false) stub_licensed_features(feature_name => false)
......
...@@ -16,7 +16,7 @@ RSpec.describe Projects::Analytics::MergeRequestAnalyticsController do ...@@ -16,7 +16,7 @@ RSpec.describe Projects::Analytics::MergeRequestAnalyticsController do
stub_licensed_features(feature_name => true) stub_licensed_features(feature_name => true)
end end
describe 'GET show' do describe 'GET #show' do
subject { get :show, params: { namespace_id: group, project_id: project } } subject { get :show, params: { namespace_id: group, project_id: project } }
before do before do
...@@ -25,6 +25,11 @@ RSpec.describe Projects::Analytics::MergeRequestAnalyticsController do ...@@ -25,6 +25,11 @@ RSpec.describe Projects::Analytics::MergeRequestAnalyticsController do
it { is_expected.to be_successful } it { is_expected.to be_successful }
it_behaves_like 'tracking unique visits', :show do
let(:request_params) { { namespace_id: group, project_id: project } }
let(:target_id) { 'p_analytics_merge_request' }
end
context 'when license is missing' do context 'when license is missing' do
before do before do
stub_licensed_features(feature_name => false) stub_licensed_features(feature_name => false)
......
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
category: analytics category: analytics
redis_slot: analytics redis_slot: analytics
aggregation: weekly aggregation: weekly
- name: g_analytics_merge_request
category: analytics
redis_slot: analytics
aggregation: weekly
- name: p_analytics_merge_request
category: analytics
redis_slot: analytics
aggregation: weekly
- name: g_edit_by_web_ide - name: g_edit_by_web_ide
category: ide_edit category: ide_edit
redis_slot: edit redis_slot: edit
......
...@@ -1022,6 +1022,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1022,6 +1022,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
'p_analytics_repo' => 123, 'p_analytics_repo' => 123,
'i_analytics_cohorts' => 123, 'i_analytics_cohorts' => 123,
'i_analytics_dev_ops_score' => 123, 'i_analytics_dev_ops_score' => 123,
'p_analytics_merge_request' => 123,
'g_analytics_merge_request' => 123,
'analytics_unique_visits_for_any_target' => 543, 'analytics_unique_visits_for_any_target' => 543,
'analytics_unique_visits_for_any_target_monthly' => 987 'analytics_unique_visits_for_any_target_monthly' => 987
} }
......
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