Commit 8821abc1 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '246494-remove-individual-checks-for-usage-ping-setting-enabled' into 'master'

Remove individual checks for usage ping setting enabled

Closes #246494

See merge request gitlab-org/gitlab!42694
parents 243aa5ab 4464cb43
......@@ -26,7 +26,6 @@ module RedisTracking
def track_unique_redis_hll_event(event_name, feature, feature_default_enabled)
return unless metric_feature_enabled?(feature, feature_default_enabled)
return unless Gitlab::CurrentSettings.usage_ping_enabled?
return unless visitor_id
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(visitor_id, event_name)
......
......@@ -15,7 +15,6 @@ module Analytics
def track_visit(target_id)
return unless Feature.enabled?(:track_unique_visits)
return unless Gitlab::CurrentSettings.usage_ping_enabled?
return unless visitor_id
Gitlab::Analytics::UniqueVisits.new.track_visit(visitor_id, target_id)
......
......@@ -544,7 +544,6 @@ module API
feature_name = "usage_data_#{event_name}"
return unless Feature.enabled?(feature_name)
return unless Gitlab::CurrentSettings.usage_ping_enabled?
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(values, event_name)
rescue => error
......
......@@ -106,7 +106,6 @@ module Gitlab
# @param values [Array|String] the values counted
def track_usage_event(event_name, values)
return unless Feature.enabled?(:"usage_data_#{event_name}", default_enabled: true)
return unless Gitlab::CurrentSettings.usage_ping_enabled?
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(values, event_name.to_s)
end
......
......@@ -36,21 +36,9 @@ RSpec.describe RedisTracking do
end
end
context 'with usage ping disabled' do
it 'does not track the event' do
stub_feature_flags(feature => true)
allow(Gitlab::CurrentSettings).to receive(:usage_ping_enabled?).and_return(false)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
get :index
end
end
context 'with feature enabled and usage ping enabled' do
context 'with feature enabled' do
before do
stub_feature_flags(feature => true)
allow(Gitlab::CurrentSettings).to receive(:usage_ping_enabled?).and_return(true)
end
context 'when user is logged in' do
......
......@@ -22,15 +22,6 @@ RSpec.describe Analytics::UniqueVisitsHelper do
helper.track_visit(target_id)
end
it 'does not track visits if usage ping is disabled' do
sign_in(current_user)
expect(Gitlab::CurrentSettings).to receive(:usage_ping_enabled?).and_return(false)
expect_any_instance_of(Gitlab::Analytics::UniqueVisits).not_to receive(:track_visit)
helper.track_visit(target_id)
end
it 'does not track visit if user is not logged in' do
expect_any_instance_of(Gitlab::Analytics::UniqueVisits).not_to receive(:track_visit)
......
......@@ -191,7 +191,7 @@ RSpec.describe API::Helpers do
describe '#increment_unique_values' do
let(:value) { '9f302fea-f828-4ca9-aef4-e10bd723c0b3' }
let(:event_name) { 'my_event' }
let(:event_name) { 'g_compliance_dashboard' }
let(:unknown_event) { 'unknown' }
let(:feature) { "usage_data_#{event_name}" }
......@@ -205,31 +205,18 @@ RSpec.describe API::Helpers do
end
it 'tracks redis hll event' do
stub_application_setting(usage_ping_enabled: true)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(value, event_name)
subject.increment_unique_values(event_name, value)
end
it 'does not track event usage ping is not enabled' do
stub_application_setting(usage_ping_enabled: false)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
subject.increment_unique_values(event_name, value)
end
it 'logs an exception for unknown event' do
stub_application_setting(usage_ping_enabled: true)
expect(Gitlab::AppLogger).to receive(:warn).with("Redis tracking event failed for event: #{unknown_event}, message: Unknown event #{unknown_event}")
subject.increment_unique_values(unknown_event, value)
end
it 'does not track event for nil values' do
stub_application_setting(usage_ping_enabled: true)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
subject.increment_unique_values(unknown_event, nil)
......
......@@ -212,7 +212,7 @@ RSpec.describe Gitlab::Utils::UsageData do
describe '#track_usage_event' do
let(:value) { '9f302fea-f828-4ca9-aef4-e10bd723c0b3' }
let(:event_name) { 'my_event' }
let(:event_name) { 'incident_management_alert_status_changed' }
let(:unknown_event) { 'unknown' }
let(:feature) { "usage_data_#{event_name}" }
......@@ -226,23 +226,12 @@ RSpec.describe Gitlab::Utils::UsageData do
end
it 'tracks redis hll event' do
stub_application_setting(usage_ping_enabled: true)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(value, event_name)
described_class.track_usage_event(event_name, value)
end
it 'does not track event when usage ping is not enabled' do
stub_application_setting(usage_ping_enabled: false)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
described_class.track_usage_event(event_name, value)
end
it 'raise an error for unknown event' do
stub_application_setting(usage_ping_enabled: true)
expect { described_class.track_usage_event(unknown_event, value) }.to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownEvent)
end
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