Class: RailsErrorDashboard::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/rails_error_dashboard/configuration.rb', line 124

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 = []
  @custom_fingerprint = nil # Lambda: ->(exception, context) { "custom_key" }
  @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)

  # Sensitive data filtering defaults - ON by default (filters passwords, tokens, credit cards, etc.)
  @filter_sensitive_data = true
  @sensitive_data_patterns = []

  # Notification throttling defaults
  @notification_minimum_severity = :low  # Notify on all severities (current behavior)
  @notification_cooldown_minutes = 5     # 5 min cooldown per error_hash (0 = disabled)
  @notification_threshold_alerts = [ 10, 50, 100, 500, 1000 ] # Occurrence milestones

  # 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_versionObject

Enhanced metrics



76
77
78
# File 'lib/rails_error_dashboard/configuration.rb', line 76

def app_version
  @app_version
end

#application_nameObject

Multi-app support - Application name



13
14
15
# File 'lib/rails_error_dashboard/configuration.rb', line 13

def application_name
  @application_name
end

#async_adapterObject

:sidekiq, :solid_queue, or :async



66
67
68
# File 'lib/rails_error_dashboard/configuration.rb', line 66

def async_adapter
  @async_adapter
end

#async_loggingObject

Async logging configuration



65
66
67
# File 'lib/rails_error_dashboard/configuration.rb', line 65

def async_logging
  @async_logging
end

#baseline_alert_cooldown_minutesObject

Minutes between alerts for same error type (default: 120)



95
96
97
# File 'lib/rails_error_dashboard/configuration.rb', line 95

def baseline_alert_cooldown_minutes
  @baseline_alert_cooldown_minutes
end

#baseline_alert_severitiesObject

Array of severities to alert on (default: [:critical, :high])



94
95
96
# File 'lib/rails_error_dashboard/configuration.rb', line 94

def baseline_alert_severities
  @baseline_alert_severities
end

#baseline_alert_threshold_std_devsObject

Number of std devs to trigger alert (default: 2.0)



93
94
95
# File 'lib/rails_error_dashboard/configuration.rb', line 93

def baseline_alert_threshold_std_devs
  @baseline_alert_threshold_std_devs
end

#custom_fingerprintObject

Custom fingerprint lambda for error deduplication When set, overrides the default ErrorHashGenerator logic. Receives (exception, context) and must return a String. Example: ->(exception, context) { “#RailsErrorDashboard::Configuration.exceptionexception.classexception.class.name:#:controller_name” }



59
60
61
# File 'lib/rails_error_dashboard/configuration.rb', line 59

def custom_fingerprint
  @custom_fingerprint
end

#custom_severity_rulesObject

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_urlObject

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_passwordObject

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_usernameObject

Dashboard authentication (always required)



6
7
8
# File 'lib/rails_error_dashboard/configuration.rb', line 6

def dashboard_username
  @dashboard_username
end

#databaseObject

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_urlObject

Discord notifications



25
26
27
# File 'lib/rails_error_dashboard/configuration.rb', line 25

def discord_webhook_url
  @discord_webhook_url
end

#enable_baseline_alertsObject

Baseline alert configuration



92
93
94
# File 'lib/rails_error_dashboard/configuration.rb', line 92

def enable_baseline_alerts
  @enable_baseline_alerts
end

#enable_co_occurring_errorsObject

Detect errors happening together



85
86
87
# File 'lib/rails_error_dashboard/configuration.rb', line 85

def enable_co_occurring_errors
  @enable_co_occurring_errors
end

#enable_discord_notificationsObject

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_notificationsObject

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_cascadesObject

Parent→child error relationships



86
87
88
# File 'lib/rails_error_dashboard/configuration.rb', line 86

def enable_error_cascades
  @enable_error_cascades
end

#enable_error_correlationObject

Version/user/time correlation



87
88
89
# File 'lib/rails_error_dashboard/configuration.rb', line 87

def enable_error_correlation
  @enable_error_correlation
end

#enable_error_subscriberObject

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_blameObject

Show git blame (default: false)



100
101
102
# File 'lib/rails_error_dashboard/configuration.rb', line 100

def enable_git_blame
  @enable_git_blame
end

#enable_internal_loggingObject

Internal logging configuration



121
122
123
# File 'lib/rails_error_dashboard/configuration.rb', line 121

def enable_internal_logging
  @enable_internal_logging
end

#enable_middlewareObject

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_patternsObject

Cyclical/burst pattern detection



89
90
91
# File 'lib/rails_error_dashboard/configuration.rb', line 89

def enable_occurrence_patterns
  @enable_occurrence_patterns
end

#enable_pagerduty_notificationsObject

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_comparisonObject

iOS vs Android analytics



88
89
90
# File 'lib/rails_error_dashboard/configuration.rb', line 88

def enable_platform_comparison
  @enable_platform_comparison
end

#enable_rate_limitingObject

Rate limiting configuration



72
73
74
# File 'lib/rails_error_dashboard/configuration.rb', line 72

def enable_rate_limiting
  @enable_rate_limiting
end

#enable_similar_errorsObject

Advanced error analysis features



84
85
86
# File 'lib/rails_error_dashboard/configuration.rb', line 84

def enable_similar_errors
  @enable_similar_errors
end

#enable_slack_notificationsObject

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_integrationObject

Source code integration (show code in backtrace)



98
99
100
# File 'lib/rails_error_dashboard/configuration.rb', line 98

def enable_source_code_integration
  @enable_source_code_integration
end

#enable_webhook_notificationsObject

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

#filter_sensitive_dataObject

Sensitive data filtering (on by default) Redacts passwords, tokens, credit cards, SSNs, etc. before storage. Uses built-in defaults + Rails’ filter_parameters + custom patterns. Set to false if you want raw data stored (you own your database).



109
110
111
# File 'lib/rails_error_dashboard/configuration.rb', line 109

def filter_sensitive_data
  @filter_sensitive_data
end

#git_branch_strategyObject

:commit_sha, :current_branch, :main (default: :commit_sha)



103
104
105
# File 'lib/rails_error_dashboard/configuration.rb', line 103

def git_branch_strategy
  @git_branch_strategy
end

#git_repository_urlObject

Git repository URL for linking commits (e.g., “github.com/user/repo”)



81
82
83
# File 'lib/rails_error_dashboard/configuration.rb', line 81

def git_repository_url
  @git_repository_url
end

#git_shaObject

Returns the value of attribute git_sha.



77
78
79
# File 'lib/rails_error_dashboard/configuration.rb', line 77

def git_sha
  @git_sha
end

#ignored_exceptionsObject

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_levelObject

Returns the value of attribute log_level.



122
123
124
# File 'lib/rails_error_dashboard/configuration.rb', line 122

def log_level
  @log_level
end

#max_backtrace_linesObject

Backtrace configuration



69
70
71
# File 'lib/rails_error_dashboard/configuration.rb', line 69

def max_backtrace_lines
  @max_backtrace_lines
end

#notification_callbacksObject (readonly)

Notification callbacks (managed via helper methods, not set directly)



118
119
120
# File 'lib/rails_error_dashboard/configuration.rb', line 118

def notification_callbacks
  @notification_callbacks
end

#notification_cooldown_minutesObject

Per-error cooldown in minutes (default: 5, 0 = disabled)



114
115
116
# File 'lib/rails_error_dashboard/configuration.rb', line 114

def notification_cooldown_minutes
  @notification_cooldown_minutes
end

#notification_email_fromObject

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_recipientsObject

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

#notification_minimum_severityObject

Notification throttling (prevents alert fatigue)



113
114
115
# File 'lib/rails_error_dashboard/configuration.rb', line 113

def notification_minimum_severity
  @notification_minimum_severity
end

#notification_threshold_alertsObject

Occurrence milestones that trigger notification (default: [10, 50, 100, 500, 1000])



115
116
117
# File 'lib/rails_error_dashboard/configuration.rb', line 115

def notification_threshold_alerts
  @notification_threshold_alerts
end

#only_show_app_code_sourceObject

Hide gems/stdlib (default: true)



102
103
104
# File 'lib/rails_error_dashboard/configuration.rb', line 102

def only_show_app_code_source
  @only_show_app_code_source
end

#pagerduty_integration_keyObject

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_minuteObject

Returns the value of attribute rate_limit_per_minute.



73
74
75
# File 'lib/rails_error_dashboard/configuration.rb', line 73

def rate_limit_per_minute
  @rate_limit_per_minute
end

#retention_daysObject

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_rateObject

Sampling rate for non-critical errors (0.0 to 1.0, default 1.0 = 100%)



62
63
64
# File 'lib/rails_error_dashboard/configuration.rb', line 62

def sampling_rate
  @sampling_rate
end

#sensitive_data_patternsObject

Additional patterns beyond Rails’ filter_parameters



110
111
112
# File 'lib/rails_error_dashboard/configuration.rb', line 110

def sensitive_data_patterns
  @sensitive_data_patterns
end

#slack_webhook_urlObject

Notifications



17
18
19
# File 'lib/rails_error_dashboard/configuration.rb', line 17

def slack_webhook_url
  @slack_webhook_url
end

#source_code_cache_ttlObject

Cache TTL in seconds (default: 3600)



101
102
103
# File 'lib/rails_error_dashboard/configuration.rb', line 101

def source_code_cache_ttl
  @source_code_cache_ttl
end

#source_code_context_linesObject

Lines before/after (default: 5)



99
100
101
# File 'lib/rails_error_dashboard/configuration.rb', line 99

def source_code_context_lines
  @source_code_context_lines
end

#total_users_for_impactObject

For user impact % calculation



78
79
80
# File 'lib/rails_error_dashboard/configuration.rb', line 78

def total_users_for_impact
  @total_users_for_impact
end

#use_separate_databaseObject

Separate database configuration



37
38
39
# File 'lib/rails_error_dashboard/configuration.rb', line 37

def use_separate_database
  @use_separate_database
end

#user_modelObject

User model (for associations)



10
11
12
# File 'lib/rails_error_dashboard/configuration.rb', line 10

def user_model
  @user_model
end

#webhook_urlsObject

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



389
390
391
# File 'lib/rails_error_dashboard/configuration.rb', line 389

def clear_total_users_cache!
  @total_users_cache = {}
end

#effective_total_usersInteger?

Get the effective total users count (auto-detected if not configured) Caches the result for 5 minutes to avoid repeated queries

Returns:

  • (Integer, nil)

    Total users count



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/rails_error_dashboard/configuration.rb', line 368

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_modelString?

Get the effective user model (auto-detected if not configured)

Returns:

  • (String, nil)

    User model class name



358
359
360
361
362
# File 'lib/rails_error_dashboard/configuration.rb', line 358

def effective_user_model
  return @user_model if @user_model.present?

  RailsErrorDashboard::Helpers::UserModelDetector.detect_user_model
end

#reset!Object

Reset configuration to defaults



226
227
228
# File 'lib/rails_error_dashboard/configuration.rb', line 226

def reset!
  initialize
end

#validate!true

Validate configuration values Raises ConfigurationError if any validation fails

Returns:

  • (true)

    if configuration is valid

Raises:



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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/rails_error_dashboard/configuration.rb', line 235

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 custom_fingerprint (must respond to .call if set)
  if custom_fingerprint && !custom_fingerprint.respond_to?(:call)
    errors << "custom_fingerprint must respond to .call (lambda, proc, or object with .call method)"
  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

  # Validate notification_minimum_severity (must be valid symbol)
  if notification_minimum_severity
    valid_notification_severities = %i[critical high medium low]
    unless valid_notification_severities.include?(notification_minimum_severity)
      errors << "notification_minimum_severity must be one of #{valid_notification_severities.inspect} " \
                "(got: #{notification_minimum_severity.inspect})"
    end
  end

  # Validate notification_cooldown_minutes (must be non-negative if set)
  if notification_cooldown_minutes && notification_cooldown_minutes < 0
    errors << "notification_cooldown_minutes must be 0 or greater (got: #{notification_cooldown_minutes})"
  end

  # Validate notification_threshold_alerts (must be array of positive integers if set)
  if notification_threshold_alerts && !notification_threshold_alerts.is_a?(Array)
    errors << "notification_threshold_alerts must be an Array (got: #{notification_threshold_alerts.class})"
  end

  # Raise exception if any errors found
  raise ConfigurationError, errors if errors.any?

  true
end