summaryrefslogtreecommitdiff
path: root/lib/product_analytics/settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/product_analytics/settings.rb')
-rw-r--r--lib/product_analytics/settings.rb33
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/product_analytics/settings.rb b/lib/product_analytics/settings.rb
index 9e38adf8a13..5d52965f5be 100644
--- a/lib/product_analytics/settings.rb
+++ b/lib/product_analytics/settings.rb
@@ -6,21 +6,32 @@ module ProductAnalytics
%w[product_analytics_data_collector_host product_analytics_clickhouse_connection_string] +
%w[cube_api_base_url cube_api_key]).freeze
- class << self
- def enabled?
- ::Gitlab::CurrentSettings.product_analytics_enabled? && configured?
+ def initialize(project:)
+ @project = project
+ end
+
+ def enabled?
+ ::Gitlab::CurrentSettings.product_analytics_enabled? && configured?
+ end
+
+ # rubocop:disable GitlabSecurity/PublicSend
+ def configured?
+ CONFIG_KEYS.all? do |key|
+ @project.project_setting.public_send(key).present? ||
+ ::Gitlab::CurrentSettings.public_send(key).present?
end
+ end
- def configured?
- CONFIG_KEYS.all? do |key|
- ::Gitlab::CurrentSettings.public_send(key)&.present? # rubocop:disable GitlabSecurity/PublicSend
- end
+ CONFIG_KEYS.each do |key|
+ define_method key.to_sym do
+ @project.project_setting.public_send(key).presence || ::Gitlab::CurrentSettings.public_send(key)
end
+ end
+ # rubocop:enable GitlabSecurity/PublicSend
- CONFIG_KEYS.each do |key|
- define_method key.to_sym do
- ::Gitlab::CurrentSettings.public_send(key) # rubocop:disable GitlabSecurity/PublicSend
- end
+ class << self
+ def for_project(project)
+ ProductAnalytics::Settings.new(project: project)
end
end
end