Class: RailsErrorDashboard::Configuration
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Configuration
- Defined in:
- lib/rails_error_dashboard/configuration.rb
Instance Attribute Summary collapse
-
#app_version ⇒ Object
Enhanced metrics.
-
#application_name ⇒ Object
Multi-app support - Application name.
-
#async_adapter ⇒ Object
:sidekiq, :solid_queue, or :async.
-
#async_logging ⇒ Object
Async logging configuration.
-
#baseline_alert_cooldown_minutes ⇒ Object
Minutes between alerts for same error type (default: 120).
-
#baseline_alert_severities ⇒ Object
Array of severities to alert on (default: [:critical, :high]).
-
#baseline_alert_threshold_std_devs ⇒ Object
Number of std devs to trigger alert (default: 2.0).
-
#custom_severity_rules ⇒ Object
Advanced configuration options Custom severity classification rules (hash of error_type => severity).
-
#dashboard_base_url ⇒ Object
Returns the value of attribute dashboard_base_url.
-
#dashboard_password ⇒ Object
Returns the value of attribute dashboard_password.
-
#dashboard_username ⇒ Object
Dashboard authentication (always required).
-
#database ⇒ Object
Database connection name for shared error dashboard DB.
-
#discord_webhook_url ⇒ Object
Discord notifications.
-
#enable_baseline_alerts ⇒ Object
Baseline alert configuration.
-
#enable_co_occurring_errors ⇒ Object
Detect errors happening together.
-
#enable_discord_notifications ⇒ Object
Returns the value of attribute enable_discord_notifications.
-
#enable_email_notifications ⇒ Object
Returns the value of attribute enable_email_notifications.
-
#enable_error_cascades ⇒ Object
Parent→child error relationships.
-
#enable_error_correlation ⇒ Object
Version/user/time correlation.
-
#enable_error_subscriber ⇒ Object
Enable/disable Rails.error subscriber.
-
#enable_git_blame ⇒ Object
Show git blame (default: false).
-
#enable_internal_logging ⇒ Object
Internal logging configuration.
-
#enable_middleware ⇒ Object
Enable/disable error catching middleware.
-
#enable_occurrence_patterns ⇒ Object
Cyclical/burst pattern detection.
-
#enable_pagerduty_notifications ⇒ Object
Returns the value of attribute enable_pagerduty_notifications.
-
#enable_platform_comparison ⇒ Object
iOS vs Android analytics.
-
#enable_rate_limiting ⇒ Object
Rate limiting configuration.
-
#enable_similar_errors ⇒ Object
Advanced error analysis features.
-
#enable_slack_notifications ⇒ Object
Returns the value of attribute enable_slack_notifications.
-
#enable_source_code_integration ⇒ Object
Source code integration (show code in backtrace).
-
#enable_webhook_notifications ⇒ Object
Returns the value of attribute enable_webhook_notifications.
-
#git_branch_strategy ⇒ Object
:commit_sha, :current_branch, :main (default: :commit_sha).
-
#git_repository_url ⇒ Object
Git repository URL for linking commits (e.g., “github.com/user/repo”).
-
#git_sha ⇒ Object
Returns the value of attribute git_sha.
-
#ignored_exceptions ⇒ Object
Exceptions to ignore (array of strings, regexes, or classes).
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#max_backtrace_lines ⇒ Object
Backtrace configuration.
-
#notification_callbacks ⇒ Object
readonly
Notification callbacks (managed via helper methods, not set directly).
-
#notification_email_from ⇒ Object
Returns the value of attribute notification_email_from.
-
#notification_email_recipients ⇒ Object
Returns the value of attribute notification_email_recipients.
-
#only_show_app_code_source ⇒ Object
Hide gems/stdlib (default: true).
-
#pagerduty_integration_key ⇒ Object
PagerDuty notifications (critical errors only).
-
#rate_limit_per_minute ⇒ Object
Returns the value of attribute rate_limit_per_minute.
-
#retention_days ⇒ Object
Retention policy (days to keep errors).
-
#sampling_rate ⇒ Object
Sampling rate for non-critical errors (0.0 to 1.0, default 1.0 = 100%).
-
#slack_webhook_url ⇒ Object
Notifications.
-
#source_code_cache_ttl ⇒ Object
Cache TTL in seconds (default: 3600).
-
#source_code_context_lines ⇒ Object
Lines before/after (default: 5).
-
#total_users_for_impact ⇒ Object
For user impact % calculation.
-
#use_separate_database ⇒ Object
Separate database configuration.
-
#user_model ⇒ Object
User model (for associations).
-
#webhook_urls ⇒ Object
Generic webhook notifications.
Instance Method Summary collapse
-
#clear_total_users_cache! ⇒ Object
Clear the total users cache.
-
#effective_total_users ⇒ Integer?
Get the effective total users count (auto-detected if not configured) Caches the result for 5 minutes to avoid repeated queries.
-
#effective_user_model ⇒ String?
Get the effective user model (auto-detected if not configured).
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#reset! ⇒ Object
Reset configuration to defaults.
-
#validate! ⇒ true
Validate configuration values Raises ConfigurationError if any validation fails.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/rails_error_dashboard/configuration.rb', line 106 def initialize # Default values - Authentication is ALWAYS required @dashboard_username = ENV.fetch("ERROR_DASHBOARD_USER", "gandalf") @dashboard_password = ENV.fetch("ERROR_DASHBOARD_PASSWORD", "youshallnotpass") @user_model = nil # Auto-detect if not set # Multi-app support defaults @application_name = ENV["APPLICATION_NAME"] # Auto-detected if not set @database = nil # Use primary database by default # Notification settings (disabled by default - enable during installation or in initializer) @slack_webhook_url = ENV["SLACK_WEBHOOK_URL"] @notification_email_recipients = ENV.fetch("ERROR_NOTIFICATION_EMAILS", "").split(",").map(&:strip) @notification_email_from = ENV.fetch("ERROR_NOTIFICATION_FROM", "errors@example.com") @dashboard_base_url = ENV["DASHBOARD_BASE_URL"] @enable_slack_notifications = false @enable_email_notifications = false # Discord notification settings @discord_webhook_url = ENV["DISCORD_WEBHOOK_URL"] @enable_discord_notifications = false # PagerDuty notification settings (critical errors only) @pagerduty_integration_key = ENV["PAGERDUTY_INTEGRATION_KEY"] @enable_pagerduty_notifications = false # Generic webhook settings (array of URLs) @webhook_urls = ENV.fetch("WEBHOOK_URLS", "").split(",").map(&:strip).reject(&:empty?) @enable_webhook_notifications = false @use_separate_database = ENV.fetch("USE_SEPARATE_ERROR_DB", "false") == "true" # Retention policy - nil means keep forever (no automatic deletion) # Users can run 'rails error_dashboard:cleanup_resolved DAYS=90' to manually clean up @retention_days = nil @enable_middleware = true @enable_error_subscriber = true # Advanced configuration defaults @custom_severity_rules = {} @ignored_exceptions = [] @sampling_rate = 1.0 # 100% by default @async_logging = false @async_adapter = :sidekiq # Battle-tested default @max_backtrace_lines = 100 # Matches industry standard (Rollbar, Airbrake) # Rate limiting defaults @enable_rate_limiting = false # OFF by default (opt-in) @rate_limit_per_minute = 100 # Requests per minute per IP for API endpoints # Enhanced metrics defaults @app_version = ENV["APP_VERSION"] @git_sha = ENV["GIT_SHA"] @total_users_for_impact = nil # Auto-detect if not set @git_repository_url = ENV["GIT_REPOSITORY_URL"] # Advanced error analysis features (all OFF by default - opt-in) @enable_similar_errors = false # Fuzzy error matching @enable_co_occurring_errors = false # Co-occurring error detection @enable_error_cascades = false # Error cascade detection @enable_error_correlation = false # Version/user/time correlation @enable_platform_comparison = false # Platform health comparison @enable_occurrence_patterns = false # Pattern detection # Baseline alert defaults @enable_baseline_alerts = false # OFF by default (opt-in) @baseline_alert_threshold_std_devs = ENV.fetch("BASELINE_ALERT_THRESHOLD", "2.0").to_f @baseline_alert_severities = [ :critical, :high ] # Alert on critical and high severity anomalies @baseline_alert_cooldown_minutes = ENV.fetch("BASELINE_ALERT_COOLDOWN", "120").to_i # Source code integration defaults - OFF by default (opt-in) @enable_source_code_integration = false # Master switch @source_code_context_lines = 5 # Show ±5 lines around target line @enable_git_blame = false # Show git blame info @source_code_cache_ttl = 3600 # 1 hour cache @only_show_app_code_source = true # Hide gem/vendor code for security @git_branch_strategy = :commit_sha # Use error's git_sha (most accurate) # Internal logging defaults - SILENT by default @enable_internal_logging = false # Opt-in for debugging @log_level = :silent # Silent by default, use :debug, :info, :warn, :error, or :silent @notification_callbacks = { error_logged: [], critical_error: [], error_resolved: [] } end |
Instance Attribute Details
#app_version ⇒ Object
Enhanced metrics
70 71 72 |
# File 'lib/rails_error_dashboard/configuration.rb', line 70 def app_version @app_version end |
#application_name ⇒ Object
Multi-app support - Application name
13 14 15 |
# File 'lib/rails_error_dashboard/configuration.rb', line 13 def application_name @application_name end |
#async_adapter ⇒ Object
:sidekiq, :solid_queue, or :async
60 61 62 |
# File 'lib/rails_error_dashboard/configuration.rb', line 60 def async_adapter @async_adapter end |
#async_logging ⇒ Object
Async logging configuration
59 60 61 |
# File 'lib/rails_error_dashboard/configuration.rb', line 59 def async_logging @async_logging end |
#baseline_alert_cooldown_minutes ⇒ Object
Minutes between alerts for same error type (default: 120)
89 90 91 |
# File 'lib/rails_error_dashboard/configuration.rb', line 89 def baseline_alert_cooldown_minutes @baseline_alert_cooldown_minutes end |
#baseline_alert_severities ⇒ Object
Array of severities to alert on (default: [:critical, :high])
88 89 90 |
# File 'lib/rails_error_dashboard/configuration.rb', line 88 def baseline_alert_severities @baseline_alert_severities end |
#baseline_alert_threshold_std_devs ⇒ Object
Number of std devs to trigger alert (default: 2.0)
87 88 89 |
# File 'lib/rails_error_dashboard/configuration.rb', line 87 def baseline_alert_threshold_std_devs @baseline_alert_threshold_std_devs end |
#custom_severity_rules ⇒ Object
Advanced configuration options Custom severity classification rules (hash of error_type => severity)
50 51 52 |
# File 'lib/rails_error_dashboard/configuration.rb', line 50 def custom_severity_rules @custom_severity_rules end |
#dashboard_base_url ⇒ Object
Returns the value of attribute dashboard_base_url.
20 21 22 |
# File 'lib/rails_error_dashboard/configuration.rb', line 20 def dashboard_base_url @dashboard_base_url end |
#dashboard_password ⇒ Object
Returns the value of attribute dashboard_password.
7 8 9 |
# File 'lib/rails_error_dashboard/configuration.rb', line 7 def dashboard_password @dashboard_password end |
#dashboard_username ⇒ Object
Dashboard authentication (always required)
6 7 8 |
# File 'lib/rails_error_dashboard/configuration.rb', line 6 def dashboard_username @dashboard_username end |
#database ⇒ Object
Database connection name for shared error dashboard DB
14 15 16 |
# File 'lib/rails_error_dashboard/configuration.rb', line 14 def database @database end |
#discord_webhook_url ⇒ Object
Discord notifications
25 26 27 |
# File 'lib/rails_error_dashboard/configuration.rb', line 25 def discord_webhook_url @discord_webhook_url end |
#enable_baseline_alerts ⇒ Object
Baseline alert configuration
86 87 88 |
# File 'lib/rails_error_dashboard/configuration.rb', line 86 def enable_baseline_alerts @enable_baseline_alerts end |
#enable_co_occurring_errors ⇒ Object
Detect errors happening together
79 80 81 |
# File 'lib/rails_error_dashboard/configuration.rb', line 79 def enable_co_occurring_errors @enable_co_occurring_errors end |
#enable_discord_notifications ⇒ Object
Returns the value of attribute enable_discord_notifications.
26 27 28 |
# File 'lib/rails_error_dashboard/configuration.rb', line 26 def enable_discord_notifications @enable_discord_notifications end |
#enable_email_notifications ⇒ Object
Returns the value of attribute enable_email_notifications.
22 23 24 |
# File 'lib/rails_error_dashboard/configuration.rb', line 22 def enable_email_notifications @enable_email_notifications end |
#enable_error_cascades ⇒ Object
Parent→child error relationships
80 81 82 |
# File 'lib/rails_error_dashboard/configuration.rb', line 80 def enable_error_cascades @enable_error_cascades end |
#enable_error_correlation ⇒ Object
Version/user/time correlation
81 82 83 |
# File 'lib/rails_error_dashboard/configuration.rb', line 81 def enable_error_correlation @enable_error_correlation end |
#enable_error_subscriber ⇒ Object
Enable/disable Rails.error subscriber
46 47 48 |
# File 'lib/rails_error_dashboard/configuration.rb', line 46 def enable_error_subscriber @enable_error_subscriber end |
#enable_git_blame ⇒ Object
Show git blame (default: false)
94 95 96 |
# File 'lib/rails_error_dashboard/configuration.rb', line 94 def enable_git_blame @enable_git_blame end |
#enable_internal_logging ⇒ Object
Internal logging configuration
103 104 105 |
# File 'lib/rails_error_dashboard/configuration.rb', line 103 def enable_internal_logging @enable_internal_logging end |
#enable_middleware ⇒ Object
Enable/disable error catching middleware
43 44 45 |
# File 'lib/rails_error_dashboard/configuration.rb', line 43 def enable_middleware @enable_middleware end |
#enable_occurrence_patterns ⇒ Object
Cyclical/burst pattern detection
83 84 85 |
# File 'lib/rails_error_dashboard/configuration.rb', line 83 def enable_occurrence_patterns @enable_occurrence_patterns end |
#enable_pagerduty_notifications ⇒ Object
Returns the value of attribute enable_pagerduty_notifications.
30 31 32 |
# File 'lib/rails_error_dashboard/configuration.rb', line 30 def enable_pagerduty_notifications @enable_pagerduty_notifications end |
#enable_platform_comparison ⇒ Object
iOS vs Android analytics
82 83 84 |
# File 'lib/rails_error_dashboard/configuration.rb', line 82 def enable_platform_comparison @enable_platform_comparison end |
#enable_rate_limiting ⇒ Object
Rate limiting configuration
66 67 68 |
# File 'lib/rails_error_dashboard/configuration.rb', line 66 def enable_rate_limiting @enable_rate_limiting end |
#enable_similar_errors ⇒ Object
Advanced error analysis features
78 79 80 |
# File 'lib/rails_error_dashboard/configuration.rb', line 78 def enable_similar_errors @enable_similar_errors end |
#enable_slack_notifications ⇒ Object
Returns the value of attribute enable_slack_notifications.
21 22 23 |
# File 'lib/rails_error_dashboard/configuration.rb', line 21 def enable_slack_notifications @enable_slack_notifications end |
#enable_source_code_integration ⇒ Object
Source code integration (show code in backtrace)
92 93 94 |
# File 'lib/rails_error_dashboard/configuration.rb', line 92 def enable_source_code_integration @enable_source_code_integration end |
#enable_webhook_notifications ⇒ Object
Returns the value of attribute enable_webhook_notifications.
34 35 36 |
# File 'lib/rails_error_dashboard/configuration.rb', line 34 def enable_webhook_notifications @enable_webhook_notifications end |
#git_branch_strategy ⇒ Object
:commit_sha, :current_branch, :main (default: :commit_sha)
97 98 99 |
# File 'lib/rails_error_dashboard/configuration.rb', line 97 def git_branch_strategy @git_branch_strategy end |
#git_repository_url ⇒ Object
Git repository URL for linking commits (e.g., “github.com/user/repo”)
75 76 77 |
# File 'lib/rails_error_dashboard/configuration.rb', line 75 def git_repository_url @git_repository_url end |
#git_sha ⇒ Object
Returns the value of attribute git_sha.
71 72 73 |
# File 'lib/rails_error_dashboard/configuration.rb', line 71 def git_sha @git_sha end |
#ignored_exceptions ⇒ Object
Exceptions to ignore (array of strings, regexes, or classes)
53 54 55 |
# File 'lib/rails_error_dashboard/configuration.rb', line 53 def ignored_exceptions @ignored_exceptions end |
#log_level ⇒ Object
Returns the value of attribute log_level.
104 105 106 |
# File 'lib/rails_error_dashboard/configuration.rb', line 104 def log_level @log_level end |
#max_backtrace_lines ⇒ Object
Backtrace configuration
63 64 65 |
# File 'lib/rails_error_dashboard/configuration.rb', line 63 def max_backtrace_lines @max_backtrace_lines end |
#notification_callbacks ⇒ Object (readonly)
Notification callbacks (managed via helper methods, not set directly)
100 101 102 |
# File 'lib/rails_error_dashboard/configuration.rb', line 100 def notification_callbacks @notification_callbacks end |
#notification_email_from ⇒ Object
Returns the value of attribute notification_email_from.
19 20 21 |
# File 'lib/rails_error_dashboard/configuration.rb', line 19 def notification_email_from @notification_email_from end |
#notification_email_recipients ⇒ Object
Returns the value of attribute notification_email_recipients.
18 19 20 |
# File 'lib/rails_error_dashboard/configuration.rb', line 18 def notification_email_recipients @notification_email_recipients end |
#only_show_app_code_source ⇒ Object
Hide gems/stdlib (default: true)
96 97 98 |
# File 'lib/rails_error_dashboard/configuration.rb', line 96 def only_show_app_code_source @only_show_app_code_source end |
#pagerduty_integration_key ⇒ Object
PagerDuty notifications (critical errors only)
29 30 31 |
# File 'lib/rails_error_dashboard/configuration.rb', line 29 def pagerduty_integration_key @pagerduty_integration_key end |
#rate_limit_per_minute ⇒ Object
Returns the value of attribute rate_limit_per_minute.
67 68 69 |
# File 'lib/rails_error_dashboard/configuration.rb', line 67 def rate_limit_per_minute @rate_limit_per_minute end |
#retention_days ⇒ Object
Retention policy (days to keep errors)
40 41 42 |
# File 'lib/rails_error_dashboard/configuration.rb', line 40 def retention_days @retention_days end |
#sampling_rate ⇒ Object
Sampling rate for non-critical errors (0.0 to 1.0, default 1.0 = 100%)
56 57 58 |
# File 'lib/rails_error_dashboard/configuration.rb', line 56 def sampling_rate @sampling_rate end |
#slack_webhook_url ⇒ Object
Notifications
17 18 19 |
# File 'lib/rails_error_dashboard/configuration.rb', line 17 def slack_webhook_url @slack_webhook_url end |
#source_code_cache_ttl ⇒ Object
Cache TTL in seconds (default: 3600)
95 96 97 |
# File 'lib/rails_error_dashboard/configuration.rb', line 95 def source_code_cache_ttl @source_code_cache_ttl end |
#source_code_context_lines ⇒ Object
Lines before/after (default: 5)
93 94 95 |
# File 'lib/rails_error_dashboard/configuration.rb', line 93 def source_code_context_lines @source_code_context_lines end |
#total_users_for_impact ⇒ Object
For user impact % calculation
72 73 74 |
# File 'lib/rails_error_dashboard/configuration.rb', line 72 def total_users_for_impact @total_users_for_impact end |
#use_separate_database ⇒ Object
Separate database configuration
37 38 39 |
# File 'lib/rails_error_dashboard/configuration.rb', line 37 def use_separate_database @use_separate_database end |
#user_model ⇒ Object
User model (for associations)
10 11 12 |
# File 'lib/rails_error_dashboard/configuration.rb', line 10 def user_model @user_model end |
#webhook_urls ⇒ Object
Generic webhook notifications
33 34 35 |
# File 'lib/rails_error_dashboard/configuration.rb', line 33 def webhook_urls @webhook_urls end |
Instance Method Details
#clear_total_users_cache! ⇒ Object
Clear the total users cache
337 338 339 |
# File 'lib/rails_error_dashboard/configuration.rb', line 337 def clear_total_users_cache! @total_users_cache = {} end |
#effective_total_users ⇒ Integer?
Get the effective total users count (auto-detected if not configured) Caches the result for 5 minutes to avoid repeated queries
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/rails_error_dashboard/configuration.rb', line 316 def effective_total_users return @total_users_for_impact if @total_users_for_impact.present? # Cache auto-detected value for 5 minutes @total_users_cache ||= {} cache_key = :auto_detected_count cached_at = @total_users_cache[:cached_at] if cached_at && (Time.current - cached_at) < 300 # 5 minutes return @total_users_cache[cache_key] end count = RailsErrorDashboard::Helpers::UserModelDetector.detect_total_users @total_users_cache[cache_key] = count @total_users_cache[:cached_at] = Time.current count end |
#effective_user_model ⇒ String?
Get the effective user model (auto-detected if not configured)
306 307 308 309 310 |
# File 'lib/rails_error_dashboard/configuration.rb', line 306 def effective_user_model return @user_model if @user_model.present? RailsErrorDashboard::Helpers::UserModelDetector.detect_user_model end |
#reset! ⇒ Object
Reset configuration to defaults
198 199 200 |
# File 'lib/rails_error_dashboard/configuration.rb', line 198 def reset! initialize end |
#validate! ⇒ true
Validate configuration values Raises ConfigurationError if any validation fails
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/rails_error_dashboard/configuration.rb', line 207 def validate! errors = [] # Validate sampling_rate (must be between 0.0 and 1.0) if sampling_rate && (sampling_rate < 0.0 || sampling_rate > 1.0) errors << "sampling_rate must be between 0.0 and 1.0 (got: #{sampling_rate})" end # Validate retention_days (must be positive) if retention_days && retention_days < 1 errors << "retention_days must be at least 1 day (got: #{retention_days})" end # Validate max_backtrace_lines (must be positive) if max_backtrace_lines && max_backtrace_lines < 1 errors << "max_backtrace_lines must be at least 1 (got: #{max_backtrace_lines})" end # Validate rate_limit_per_minute (must be positive if rate limiting enabled) if enable_rate_limiting && rate_limit_per_minute && rate_limit_per_minute < 1 errors << "rate_limit_per_minute must be at least 1 (got: #{rate_limit_per_minute})" end # Validate baseline alert threshold (must be positive) if enable_baseline_alerts && baseline_alert_threshold_std_devs && baseline_alert_threshold_std_devs <= 0 errors << "baseline_alert_threshold_std_devs must be positive (got: #{baseline_alert_threshold_std_devs})" end # Validate baseline alert cooldown (must be positive) if enable_baseline_alerts && baseline_alert_cooldown_minutes && baseline_alert_cooldown_minutes < 1 errors << "baseline_alert_cooldown_minutes must be at least 1 (got: #{baseline_alert_cooldown_minutes})" end # Validate baseline alert severities (must be valid symbols) if enable_baseline_alerts && baseline_alert_severities valid_severities = %i[critical high medium low] invalid_severities = baseline_alert_severities - valid_severities if invalid_severities.any? errors << "baseline_alert_severities contains invalid values: #{invalid_severities.inspect}. " \ "Valid options: #{valid_severities.inspect}" end end # Validate async_adapter (must be valid adapter) if async_logging && async_adapter valid_adapters = %i[sidekiq solid_queue async] unless valid_adapters.include?(async_adapter) errors << "async_adapter must be one of #{valid_adapters.inspect} (got: #{async_adapter.inspect})" end end # Validate notification dependencies if enable_slack_notifications && (slack_webhook_url.nil? || slack_webhook_url.strip.empty?) errors << "slack_webhook_url is required when enable_slack_notifications is true" end if enable_email_notifications && notification_email_recipients.empty? errors << "notification_email_recipients is required when enable_email_notifications is true" end if enable_discord_notifications && (discord_webhook_url.nil? || discord_webhook_url.strip.empty?) errors << "discord_webhook_url is required when enable_discord_notifications is true" end if enable_pagerduty_notifications && (pagerduty_integration_key.nil? || pagerduty_integration_key.strip.empty?) errors << "pagerduty_integration_key is required when enable_pagerduty_notifications is true" end if enable_webhook_notifications && webhook_urls.empty? errors << "webhook_urls is required when enable_webhook_notifications is true" end # Validate separate database configuration if use_separate_database && (database.nil? || database.to_s.strip.empty?) errors << "database configuration is required when use_separate_database is true" end # Validate log level (must be valid symbol) if log_level valid_log_levels = %i[debug info warn error fatal silent] unless valid_log_levels.include?(log_level) errors << "log_level must be one of #{valid_log_levels.inspect} (got: #{log_level.inspect})" end end # Validate total_users_for_impact (must be positive if set) if total_users_for_impact && total_users_for_impact < 1 errors << "total_users_for_impact must be at least 1 (got: #{total_users_for_impact})" end # Raise exception if any errors found raise ConfigurationError, errors if errors.any? true end |