Commit 14d5be81 authored by Victor Zagorodny's avatar Victor Zagorodny

Protect group overview usage ping w/ feature flag

user_preferences key is includes into system usage
data only if group_overview_security_dashboard
feature flag is enabled; see
https://gitlab.com/gitlab-org/gitlab-ee/issues/7048
parent 69b0d9ff
...@@ -92,10 +92,14 @@ module EE ...@@ -92,10 +92,14 @@ module EE
# the base key part after a corresponding User model attribute, use its possible values as suffix values. # the base key part after a corresponding User model attribute, use its possible values as suffix values.
override :user_preferences_usage override :user_preferences_usage
def user_preferences_usage def user_preferences_usage
super.merge( super.tap do |user_prefs_usage|
group_overview_details: count(::User.active.group_view_details), if ::Feature.enabled?(:group_overview_security_dashboard)
group_overview_security_dashboard: count(::User.active.group_view_security_dashboard) user_prefs_usage.merge!(
) group_overview_details: count(::User.active.group_view_details),
group_overview_security_dashboard: count(::User.active.group_view_security_dashboard)
)
end
end
end end
override :system_usage_data override :system_usage_data
......
...@@ -100,12 +100,17 @@ describe Gitlab::UsageData do ...@@ -100,12 +100,17 @@ describe Gitlab::UsageData do
expect(count_data[:sast_jobs]).to eq(1) expect(count_data[:sast_jobs]).to eq(1)
end end
it 'gathers security-related preferences usage data' do it 'gathers group overview preferences usage data' do
expect(subject[:counts][:user_preferences]).to eq( expect(subject[:counts][:user_preferences]).to eq(
group_overview_details: User.active.count - 2, # we have exactly 2 active users with security dashboard set group_overview_details: User.active.count - 2, # we have exactly 2 active users with security dashboard set
group_overview_security_dashboard: 2 group_overview_security_dashboard: 2
) )
end end
it 'does not gather group overview preferences usage data when the feature is disabled' do
stub_feature_flags(group_overview_security_dashboard: false)
expect(subject[:counts].keys).not_to include(:user_preferences)
end
end end
describe '#features_usage_data_ee' do describe '#features_usage_data_ee' do
......
...@@ -95,8 +95,11 @@ module Gitlab ...@@ -95,8 +95,11 @@ module Gitlab
} }
.merge(services_usage) .merge(services_usage)
.merge(approximate_counts) .merge(approximate_counts)
.merge(user_preferences: user_preferences_usage) }.tap do |data|
} if Feature.enabled?(:group_overview_security_dashboard)
data[:counts][:user_preferences] = user_preferences_usage
end
end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -129,6 +129,11 @@ describe Gitlab::UsageData do ...@@ -129,6 +129,11 @@ describe Gitlab::UsageData do
)) ))
end end
it 'does not gather user preferences usage data when the feature is disabled' do
stub_feature_flags(group_overview_security_dashboard: false)
expect(subject[:counts].keys).not_to include(:user_preferences)
end
it 'gathers projects data correctly' do it 'gathers projects data correctly' do
count_data = subject[:counts] count_data = subject[:counts]
......
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