Skip to content
代码片段 群组 项目
提交 ce685608 编辑于 作者: Max Woolf's avatar Max Woolf 提交者: Michael Kozono
浏览文件

Add redis counter for viewing dashboard

When viewing a specific analytics dashboard
we should instrument that as a redis counter

EE: true
Changelog: added
上级 7e7d9b58
No related branches found
No related tags found
无相关合并请求
...@@ -13,7 +13,10 @@ class DashboardsController < Projects::ApplicationController ...@@ -13,7 +13,10 @@ class DashboardsController < Projects::ApplicationController
push_frontend_feature_flag(:product_analytics_snowplow_support) push_frontend_feature_flag(:product_analytics_snowplow_support)
end end
def index; end def index
::Gitlab::UsageDataCounters::ProductAnalyticsCounter.count(:view_dashboard) if
params[:vueroute].present?
end
private private
......
---
key_path: counts.analytics_dashboard_views
description: "Number of views of any single product analytics dashboard"
product_section: dev
product_stage: analytics
product_group: product_analytics
value_type: number
status: active
milestone: "16.0"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119328
time_frame: 7d
data_source: redis
data_category: optional
instrumentation_class: RedisMetric
options:
prefix: product_analytics
event: view_dashboard
distribution:
- ee
tier:
- ultimate
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class ProductAnalyticsCounter < BaseCounter
KNOWN_EVENTS = %w[view_dashboard].freeze
PREFIX = 'product_analytics'
end
end
end
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'does not increment counter' do
expect(Gitlab::UsageDataCounters::ProductAnalyticsCounter).not_to receive(:count)
send_dashboards_request
end
end end
shared_examples 'returns success' do shared_examples 'returns success' do
...@@ -27,6 +33,12 @@ ...@@ -27,6 +33,12 @@
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
it 'increments counter' do
expect(Gitlab::UsageDataCounters::ProductAnalyticsCounter).to receive(:count).with(:view_dashboard)
send_dashboards_request
end
end end
context 'with the feature flag disabled' do context 'with the feature flag disabled' do
...@@ -39,7 +51,7 @@ ...@@ -39,7 +51,7 @@
context 'with the feature flag enabled' do context 'with the feature flag enabled' do
before do before do
stub_feature_flags(combined_project_analytics_dashboards: true) stub_feature_flags(combined_analytics_dashboards: true)
end end
context 'without the licensed feature' do context 'without the licensed feature' do
...@@ -68,13 +80,19 @@ ...@@ -68,13 +80,19 @@
it_behaves_like params[:example_to_run] it_behaves_like params[:example_to_run]
end end
it 'does not count views for the dashboard listing' do
expect(Gitlab::UsageDataCounters::ProductAnalyticsCounter).not_to receive(:count)
get project_analytics_dashboards_path(project)
end
end end
end end
private private
def send_dashboards_request def send_dashboards_request
get project_analytics_dashboards_path(project) get project_analytics_dashboards_path(project, vueroute: 'dashboard_audience')
end end
end end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册