Commit 0680baff authored by Mark Chao's avatar Mark Chao

Merge branch 'jnnkl-rediscounter-definition' into 'master'

Add missing counters for the license_compliance tracking

See merge request gitlab-org/gitlab!77866
parents e52dfe0e fd75f002
---
name: usage_data_users_clicking_license_testing_visiting_external_website
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76917
rollout_issue_url:
milestone: '14.7'
type: development
group: group::secure
default_enabled: false
---
name: usage_data_users_visiting_testing_license_compliance_full_report
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76917
rollout_issue_url:
milestone: '14.7'
type: development
group: group::secure
default_enabled: false
\ No newline at end of file
data_category: optional
key_path: counts.users_clicking_license_testing_visiting_external_website
description: Total number of clicks on licence-compliance details to visit external information website
product_section: sec
product_stage: secure
product_group: group::static analysis
product_category: dependency_scanning
value_type: number
status: active
milestone: '14.7'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76917
time_frame: all
data_source: redis
distribution:
- ee
tier:
- premium
- ultimate
\ No newline at end of file
data_category: optional
key_path: counts.users_visiting_testing_license_compliance_full_report
description: Total number of clicks on testing_license_compliance_full_report button
product_section: sec
product_stage: secure
product_group: group::static analysis
product_category: dependency_scanning
value_type: number
status: active
milestone: '14.7'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76917
time_frame: all
data_source: redis
distribution:
- ee
tier:
- premium
- ultimate
......@@ -54,15 +54,6 @@ module EE
class_methods do
extend ::Gitlab::Utils::Override
override :usage_data_counters
def usage_data_counters
super + [
::Gitlab::UsageDataCounters::LicensesList,
::Gitlab::StatusPage::UsageDataCounters::IncidentCounter,
::Gitlab::UsageDataCounters::NetworkPolicyCounter
]
end
override :uncached_data
def uncached_data
with_finished_at(:recording_ee_finished_at) do
......
# frozen_string_literal: true
module EE
module Gitlab
module UsageDataCounters
extend ActiveSupport::Concern
class_methods do
extend ::Gitlab::Utils::Override
override :counters
def counters
super + [
::Gitlab::UsageDataCounters::LicensesList,
::Gitlab::StatusPage::UsageDataCounters::IncidentCounter,
::Gitlab::UsageDataCounters::NetworkPolicyCounter,
::Gitlab::UsageDataCounters::LicenseTestingCounter
]
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class LicenseTestingCounter < BaseCounter
KNOWN_EVENTS = %w[clicking_license_testing_visiting_external_website visiting_testing_license_compliance_full_report].freeze
PREFIX = 'users'
end
end
end
......@@ -120,6 +120,8 @@ RSpec.describe Gitlab::UsageData do
template_repositories
network_policy_forwards
network_policy_drops
users_visiting_testing_license_compliance_full_report
users_clicking_license_testing_visiting_external_website
))
expect(count_data[:status_page_projects]).to eq(1)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::UsageData do
let_it_be(:user) { create(:user) }
describe 'POST /usage_data/increment_counter' do
let(:endpoint) { '/usage_data/increment_counter' }
context 'with authentication' do
before do
stub_feature_flags(usage_data_api: true)
stub_application_setting(usage_ping_enabled: true)
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(true)
end
context 'with correct params' do
using RSpec::Parameterized::TableSyntax
where(:prefix, :event) do
'users' | 'clicking_license_testing_visiting_external_website'
'users' | 'visiting_testing_license_compliance_full_report'
end
before do
stub_application_setting(usage_ping_enabled: true)
stub_feature_flags(usage_data_api: true)
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(true)
stub_feature_flags("usage_data_#{prefix}_#{event}" => true)
end
with_them do
it 'returns status :ok' do
expect(::Gitlab::UsageDataCounters::BaseCounter).to receive(:count).with(event)
post api(endpoint, user), params: { event: "#{prefix}_#{event}" }
expect(response).to have_gitlab_http_status(:ok)
end
end
end
end
end
end
......@@ -39,3 +39,5 @@ module Gitlab
end
end
end
Gitlab::UsageDataCounters.prepend_mod_with('Gitlab::UsageDataCounters')
......@@ -44,7 +44,9 @@ module RuboCop
DYNAMIC_FEATURE_FLAGS = [
:usage_data_static_site_editor_commits, # https://gitlab.com/gitlab-org/gitlab/-/issues/284082
:usage_data_static_site_editor_merge_requests # https://gitlab.com/gitlab-org/gitlab/-/issues/284083
:usage_data_static_site_editor_merge_requests, # https://gitlab.com/gitlab-org/gitlab/-/issues/284083
:usage_data_users_clicking_license_testing_visiting_external_website, # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77866
:usage_data_users_visiting_testing_license_compliance_full_report # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77866
].freeze
class << self
......
......@@ -57,13 +57,26 @@ RSpec.describe API::UsageData do
end
end
%w[merge_requests commits].each do |postfix|
context 'with correct params' do
let(:known_event_postfix) { postfix }
context 'with correct params' do
using RSpec::Parameterized::TableSyntax
where(:prefix, :event) do
'static_site_editor' | 'merge_requests'
'static_site_editor' | 'commits'
end
before do
stub_application_setting(usage_ping_enabled: true)
stub_feature_flags(usage_data_api: true)
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(true)
stub_feature_flags("usage_data_#{prefix}_#{event}" => true)
end
with_them do
it 'returns status :ok' do
expect(Gitlab::UsageDataCounters::BaseCounter).to receive(:count).with(event)
it 'returns status ok' do
expect(Gitlab::UsageDataCounters::BaseCounter).to receive(:count).with(known_event_postfix)
post api(endpoint, user), params: { event: known_event }
post api(endpoint, user), params: { event: "#{prefix}_#{event}" }
expect(response).to have_gitlab_http_status(:ok)
end
......
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