debian-mirror-gitlab/lib/product_analytics/settings.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Ruby
Raw Normal View History

2023-06-20 00:43:36 +05:30
# frozen_string_literal: true
module ProductAnalytics
class Settings
CONFIG_KEYS = (%w[jitsu_host jitsu_project_xid jitsu_administrator_email jitsu_administrator_password] +
%w[product_analytics_data_collector_host product_analytics_clickhouse_connection_string] +
%w[cube_api_base_url cube_api_key]).freeze
2023-07-09 08:55:56 +05:30
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?
2023-06-20 00:43:36 +05:30
end
2023-07-09 08:55:56 +05:30
end
2023-06-20 00:43:36 +05:30
2023-07-09 08:55:56 +05:30
CONFIG_KEYS.each do |key|
define_method key.to_sym do
@project.project_setting.public_send(key).presence || ::Gitlab::CurrentSettings.public_send(key)
2023-06-20 00:43:36 +05:30
end
2023-07-09 08:55:56 +05:30
end
# rubocop:enable GitlabSecurity/PublicSend
2023-06-20 00:43:36 +05:30
2023-07-09 08:55:56 +05:30
class << self
def for_project(project)
ProductAnalytics::Settings.new(project: project)
2023-06-20 00:43:36 +05:30
end
end
end
end