Welcome to mirror list, hosted at ThFree Co, Russian Federation.

settings.rb « product_analytics « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5d52965f5bebdf15006106b7f251d835416e8b3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

    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

    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

    class << self
      def for_project(project)
        ProductAnalytics::Settings.new(project: project)
      end
    end
  end
end