Commit a2f233bb authored by Nikolay Belokolodov's avatar Nikolay Belokolodov Committed by Douglas Barbosa Alexandre

Add a metric to track usage of the new Export Payload button

Redis count metric is added
parent b4bfc7b0
......@@ -66,7 +66,12 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
render html: Gitlab::Highlight.highlight('payload.json', usage_data_json, language: 'json')
end
format.json { render json: Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values, cached: true).to_json }
format.json do
Gitlab::UsageDataCounters::ServiceUsageDataCounter.count(:download_payload_click)
render json: Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values, cached: true).to_json
end
end
end
......
---
key_path: counts.service_usage_data_download_payload_click
description: Count Download Payload button clicks
data_category: optional
name: count_promoted_issues
product_section: growth
product_stage: growth
product_group: group::product intelligence
product_category: collection
value_type: number
status: active
time_frame: all
data_source: redis
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
performance_indicator_type: []
milestone: "14.9"
......@@ -16,7 +16,8 @@ module Gitlab
DesignsCounter,
KubernetesAgentCounter,
StaticSiteEditorCounter,
DiffsCounter
DiffsCounter,
ServiceUsageDataCounter
].freeze
UsageDataCounterError = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab::UsageDataCounters
class ServiceUsageDataCounter < BaseCounter
KNOWN_EVENTS = %w[download_payload_click].freeze
PREFIX = 'service_usage_data'
end
end
......@@ -81,6 +81,18 @@ RSpec.describe Admin::ApplicationSettingsController, :do_not_mock_admin_mode_set
expect(body).to include('counts')
expect(response).to have_gitlab_http_status(:ok)
end
describe 'usage data counter' do
let(:counter) { Gitlab::UsageDataCounters::ServiceUsageDataCounter }
it 'incremented when json generated' do
expect { get :usage_data, format: :json }.to change { counter.read(:download_payload_click) }.by(1)
end
it 'not incremented when html format requested' do
expect { get :usage_data }.not_to change { counter.read(:download_payload_click) }
end
end
end
describe 'PUT #update' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::ServiceUsageDataCounter do
it_behaves_like 'a redis usage counter', 'Service Usage Data', :download_payload_click
end
......@@ -129,6 +129,7 @@ module UsageDataHelpers
uploads
web_hooks
user_preferences_user_gitpod_enabled
service_usage_data_download_payload_click
).push(*SMAU_KEYS)
USAGE_DATA_KEYS = %i(
......
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