Skip to content
Snippets Groups Projects
Commit 3d9fe03c authored by Max Woolf's avatar Max Woolf Committed by Allen Cook
Browse files

Track unique users viewing an analytics dashboard

Adds a HLL usage metric for any user who visits a dashboard
in a particular week.

Changelog: added
EE: true
parent 0a62a604
No related branches found
No related tags found
2 merge requests!122182Track unique users viewing an analytics dashboard,!119439Draft: Prevent file variable content expansion in downstream pipeline
......@@ -13,11 +13,9 @@ class DashboardsController < Projects::ApplicationController
push_frontend_feature_flag(:product_analytics_snowplow_support)
push_frontend_feature_flag(:combined_analytics_dashboards_editor, project)
end
before_action :track_usage, only: [:index], if: :viewing_single_dashboard?
def index
::Gitlab::UsageDataCounters::ProductAnalyticsCounter.count(:view_dashboard) if
params[:vueroute].present?
end
def index; end
private
......@@ -25,6 +23,19 @@ def dashboards_enabled!
render_404 unless ::Feature.enabled?(:combined_analytics_dashboards, project) &&
project.licensed_feature_available?(:combined_project_analytics_dashboards)
end
def viewing_single_dashboard?
params[:vueroute].present?
end
def track_usage
::Gitlab::UsageDataCounters::ProductAnalyticsCounter.count(:view_dashboard)
::Gitlab::UsageDataCounters::HLLRedisCounter.track_usage_event(
'user_visited_dashboard',
current_user.id
)
end
end
end
end
---
key_path: counts.users_visiting_dashboard_weekly
description: Count of all users who have viewed at least one dashboard in the last 7 days
product_section: analytics
product_stage: analytics
product_group: product_analytics
value_type: number
status: active
milestone: "16.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122182
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
performance_indicator_type: []
distribution:
- ee
tier:
- ultimate
options:
events:
- user_visited_dashboard
......@@ -25,6 +25,13 @@
send_dashboards_request
end
it 'does not track unique user dashboard view' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter)
.not_to receive(:track_usage_event)
send_dashboards_request
end
end
shared_examples 'returns success' do
......@@ -39,6 +46,13 @@
send_dashboards_request
end
it 'tracks unique user dashboard view' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter)
.to receive(:track_usage_event).with('user_visited_dashboard', user.id)
send_dashboards_request
end
end
context 'with the feature flag disabled' do
......
......@@ -4,3 +4,5 @@
aggregation: weekly
- name: user_created_analytics_dashboard
aggregation: weekly
- name: user_visited_dashboard
aggregation: weekly
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment