Commit 3ed62a3b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '276948-remove-extra-check-from-api-helpers' into 'master'

Remove check for feature flag from API helpers  [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58469
parents 2b564aa4 7014a16e
---
title: Remove unused feature flag checks
merge_request: 58469
author:
type: removed
---
name: usage_data_g_compliance_dashboard
introduced_by_url:
rollout_issue_url:
milestone:
type: development
group: group::compliance
default_enabled: true
---
name: usage_data_i_analytics_cohorts
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54329
rollout_issue_url:
milestone: '13.9'
type: development
group: group::optimize
default_enabled: true
---
name: usage_data_i_analytics_dev_ops_adoption
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57104
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326450
milestone: '13.11'
type: development
group: group::optimize
default_enabled: true
......@@ -558,10 +558,6 @@ module API
def increment_unique_values(event_name, values)
return unless values.present?
feature_flag = "usage_data_#{event_name}"
return unless Feature.enabled?(feature_flag, default_enabled: true)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: values)
rescue => error
Gitlab::AppLogger.warn("Redis tracking event failed for event: #{event_name}, message: #{error.message}")
......
......@@ -179,46 +179,23 @@ RSpec.describe API::Helpers do
let(:value) { '9f302fea-f828-4ca9-aef4-e10bd723c0b3' }
let(:event_name) { 'g_compliance_dashboard' }
let(:unknown_event) { 'unknown' }
let(:feature) { "usage_data_#{event_name}" }
before do
skip_feature_flags_yaml_validation
end
context 'with feature enabled' do
before do
stub_feature_flags(feature => true)
end
it 'tracks redis hll event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: value)
subject.increment_unique_values(event_name, value)
end
it 'tracks redis hll event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: value)
it 'logs an exception for unknown event' do
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
subject.increment_unique_values(event_name, value)
end
it 'does not track event for nil values' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
it 'logs an exception for unknown event' do
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, nil)
end
subject.increment_unique_values(unknown_event, value)
end
context 'with feature disabled' do
before do
stub_feature_flags(feature => false)
end
it 'does not track event for nil values' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
it 'does not track event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
subject.increment_unique_values(event_name, value)
end
subject.increment_unique_values(unknown_event, nil)
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