["error", "warn", "info", "debug", "trace"].freeze attr_reader :key, :label def initialize(report) @report = report @key = "config" @label = "Configuration" end def options @options ||= begin is_new_style = report[key].key?("options") option_keys = if is_new_style report.dig(key, "options") || {} else report.dig(key) || {} end clean_up_internal_config_keys!(option_keys) definitions = config_definitions keys = definitions.keys | option_keys.keys keys.map do |option| ConfigOption.new(option, report, definitions.fetch(option, {})) end end end def config_definitions # rubocop:disable return @definitions if @definitions d = {} d["active"] = { :label => "Active", :required => true, :highlight => true, :validate => proc do |option| next if option.value == true option.validations << [:error, "AppSignal is not configured as active."] end } d["name"] = { :label => "App name", :highlight => true, :required => true } if report.elixir? d["otp_app"] = { :label => "OTP app name", :highlight => true, :required => true, :since => { :elixir => "2.0.0" } } end d["log_level"] = { :label => "Log level", :since => { :ruby => "3.0.16", :elixir => "2.2.8", :nodejs => "2.2.6" }, :validate => proc do |option, _report| if option.value? && !SUPPORTED_LOG_LEVELS.include? (option.value) option.validations << [ :error, "Unknown log level. Supported levels: #{SUPPORTED_LOG_LEVELS.join(", ")}" ] end end } # Repeat for every config option end end end 8