Commit 6044b293 authored by Ryan Cobb's avatar Ryan Cobb Committed by Mayra Cabrera

Track metrics dashboard panel type

parent dd7ca3cf
...@@ -13,6 +13,7 @@ module Metrics ...@@ -13,6 +13,7 @@ module Metrics
STAGES::MetricEndpointInserter, STAGES::MetricEndpointInserter,
STAGES::VariableEndpointInserter, STAGES::VariableEndpointInserter,
STAGES::PanelIdsInserter, STAGES::PanelIdsInserter,
STAGES::TrackPanelType,
STAGES::AlertsInserter, STAGES::AlertsInserter,
STAGES::UrlValidator STAGES::UrlValidator
].freeze ].freeze
......
# frozen_string_literal: true
module Gitlab
module Metrics
module Dashboard
module Stages
class TrackPanelType < BaseStage
def transform!
for_panel_groups do |panel_group|
for_panels_in(panel_group) do |panel|
track_panel_type(panel)
end
end
end
private
def track_panel_type(panel)
panel_type = panel[:type]
Gitlab::Tracking.event('MetricsDashboard::Chart', 'chart_rendered', label: 'Chart Type', value: panel_type)
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Metrics::Dashboard::Stages::TrackPanelType do
include MetricsDashboardHelpers
let(:project) { build_stubbed(:project) }
let(:environment) { build_stubbed(:environment, project: project) }
describe '#transform!' do
subject { described_class.new(project, dashboard, environment: environment) }
let(:dashboard) { load_sample_dashboard.deep_symbolize_keys }
it 'creates tracking event' do
expect(Gitlab::Tracking).to receive(:event).with('MetricsDashboard::Chart', 'chart_rendered',
{ label: 'Chart Type', value: 'area-chart' }).at_least(:once)
subject.transform!
end
end
end
...@@ -57,6 +57,14 @@ RSpec.describe Metrics::Dashboard::CustomDashboardService, :use_clean_rails_memo ...@@ -57,6 +57,14 @@ RSpec.describe Metrics::Dashboard::CustomDashboardService, :use_clean_rails_memo
described_class.new(*service_params).get_dashboard described_class.new(*service_params).get_dashboard
end end
it 'tracks panel type' do
expect(::Gitlab::Tracking).to receive(:event).with(
'MetricsDashboard::Chart', 'chart_rendered', { label: 'Chart Type', value: 'area-chart' }
).at_least(:once)
described_class.new(*service_params).get_dashboard
end
context 'and the dashboard is then deleted' do context 'and the dashboard is then deleted' do
it 'does not return the previously cached dashboard' do it 'does not return the previously cached dashboard' do
described_class.new(*service_params).get_dashboard described_class.new(*service_params).get_dashboard
......
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