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.
-
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
-
#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).
-
#breadcrumb_buffer_size ⇒ Object
Max breadcrumbs per request (default: 40).
-
#breadcrumb_categories ⇒ Object
Which categories to capture (default: nil = all).
-
#crash_capture_path ⇒ Object
Directory for crash files (default: Dir.tmpdir).
-
#custom_fingerprint ⇒ Object
Custom fingerprint lambda for error deduplication When set, overrides the default ErrorHashGenerator logic.
-
#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.
-
#detect_swallowed_exceptions ⇒ Object
Swallowed exception detection via TracePoint(:raise) + TracePoint(:rescue) (Ruby 3.3+ only).
-
#digest_frequency ⇒ Object
:daily or :weekly (default: :daily).
-
#digest_recipients ⇒ Object
Array of emails (default: notification_email_recipients).
-
#discord_webhook_url ⇒ Object
Discord notifications.
-
#enable_actioncable_tracking ⇒ Object
ActionCable event tracking (requires enable_breadcrumbs = true).
-
#enable_activestorage_tracking ⇒ Object
ActiveStorage event tracking (requires enable_breadcrumbs = true).
-
#enable_baseline_alerts ⇒ Object
Baseline alert configuration.
-
#enable_breadcrumbs ⇒ Object
Breadcrumbs (request activity trail).
-
#enable_co_occurring_errors ⇒ Object
Detect errors happening together.
-
#enable_coverage_tracking ⇒ Object
Code path coverage (diagnostic mode — Ruby 3.2+).
-
#enable_crash_capture ⇒ Object
Process crash capture via at_exit hook.
-
#enable_diagnostic_dump ⇒ Object
On-demand diagnostic dump (rake task + dashboard endpoint).
-
#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_instance_variables ⇒ Object
Instance variable capture from tp.self (receiver object at raise time).
-
#enable_internal_logging ⇒ Object
Internal logging configuration.
-
#enable_issue_tracking ⇒ Object
Issue tracker integration (GitHub, GitLab, Codeberg/Gitea/Forgejo) One switch enables everything: issue creation, auto-create, lifecycle sync, platform state mirroring, and comment display.
-
#enable_local_variables ⇒ Object
Local variable capture via TracePoint(:raise).
-
#enable_middleware ⇒ Object
Enable/disable error catching middleware.
-
#enable_n_plus_one_detection ⇒ Object
N+1 query detection (display-time analysis of SQL breadcrumbs).
-
#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_rack_attack_tracking ⇒ Object
Rack Attack event tracking (requires enable_breadcrumbs = true).
-
#enable_rate_limiting ⇒ Object
Rate limiting configuration.
-
#enable_scheduled_digests ⇒ Object
Scheduled digests (daily/weekly summary emails).
-
#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_system_health ⇒ Object
System health snapshot (GC, memory, threads, connection pool at error time).
-
#enable_webhook_notifications ⇒ Object
Returns the value of attribute enable_webhook_notifications.
-
#filter_sensitive_data ⇒ Object
Sensitive data filtering (on by default) Redacts passwords, tokens, credit cards, SSNs, etc.
-
#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).
-
#instance_variable_filter_patterns ⇒ Object
Additional sensitive ivar patterns (default: []).
-
#instance_variable_max_count ⇒ Object
Max ivars to capture (default: 20).
-
#issue_tracker_api_url ⇒ Object
Custom API base URL for self-hosted instances.
-
#issue_tracker_auto_create_severities ⇒ Object
Auto-create for these severities (default: [:critical, :high]).
-
#issue_tracker_labels ⇒ Object
Array of label strings (default: [“bug”]).
-
#issue_tracker_provider ⇒ Object
:github, :gitlab, :codeberg (auto-detected from git_repository_url).
-
#issue_tracker_repo ⇒ Object
“owner/repo” (auto-extracted from git_repository_url).
-
#issue_tracker_token ⇒ Object
String or lambda/proc for Rails credentials.
-
#issue_webhook_secret ⇒ Object
HMAC secret — webhooks activate when this is set.
-
#local_variable_filter_patterns ⇒ Object
Additional sensitive name patterns (default: []).
-
#local_variable_max_array_items ⇒ Object
Max array items to serialize (default: 10).
-
#local_variable_max_count ⇒ Object
Max variables to capture (default: 15).
-
#local_variable_max_depth ⇒ Object
Max object nesting depth (default: 3).
-
#local_variable_max_hash_items ⇒ Object
Max hash entries to serialize (default: 20).
-
#local_variable_max_string_length ⇒ Object
Max string value length (default: 200).
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#max_backtrace_lines ⇒ Object
Backtrace configuration.
-
#n_plus_one_threshold ⇒ Object
Min repetitions to flag (default: 3, min: 2).
-
#notification_callbacks ⇒ Object
readonly
Notification callbacks (managed via helper methods, not set directly).
-
#notification_cooldown_minutes ⇒ Object
Per-error cooldown in minutes (default: 5, 0 = disabled).
-
#notification_email_from ⇒ Object
Returns the value of attribute notification_email_from.
-
#notification_email_recipients ⇒ Object
Returns the value of attribute notification_email_recipients.
-
#notification_minimum_severity ⇒ Object
Notification throttling (prevents alert fatigue).
-
#notification_threshold_alerts ⇒ Object
Occurrence milestones that trigger notification (default: [10, 50, 100, 500, 1000]).
-
#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%).
-
#sensitive_data_patterns ⇒ Object
Additional patterns beyond Rails’ filter_parameters.
-
#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).
-
#swallowed_exception_flush_interval ⇒ Object
Seconds between flushes (default: 60).
-
#swallowed_exception_ignore_classes ⇒ Object
Additional exception classes to skip (default: []).
-
#swallowed_exception_max_cache_size ⇒ Object
Max entries per thread (default: 1000).
-
#swallowed_exception_threshold ⇒ Object
Rescue ratio to flag (default: 0.95).
-
#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.
-
#default_credentials? ⇒ Boolean
Check if using default or blank demo credentials with basic auth.
-
#detect_engine_mount_path ⇒ String
Detect where the engine is mounted in the host app’s routes.
-
#effective_issue_tracker_api_url ⇒ String
Resolve the effective API base URL for the issue tracker.
-
#effective_issue_tracker_provider ⇒ Symbol?
Resolve the effective issue tracker provider (auto-detect from git_repository_url).
-
#effective_issue_tracker_repo ⇒ String?
Resolve the effective issue tracker repository (“owner/repo”).
-
#effective_issue_tracker_token ⇒ String?
Resolve the issue tracker API token (supports string or lambda).
-
#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).
-
#engine_mount_path ⇒ String
Detect the engine’s mount path from the host app routes.
-
#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 Logs warnings for non-fatal issues (e.g., Ruby version incompatibilities).
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
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 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 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 354 355 356 357 358 359 360 361 |
# File 'lib/rails_error_dashboard/configuration.rb', line 194 def initialize # Default values - Authentication is ALWAYS required @dashboard_username = ENV.fetch("ERROR_DASHBOARD_USER", "gandalf") @dashboard_password = ENV.fetch("ERROR_DASHBOARD_PASSWORD", "youshallnotpass") @authenticate_with = nil @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 # Scheduled digest defaults - OFF by default (opt-in) @enable_scheduled_digests = false @digest_frequency = :daily @digest_recipients = nil # falls back to notification_email_recipients @use_separate_database = ENV.fetch("USE_SEPARATE_ERROR_DB", "false") == "true" # Retention policy - days to keep errors before automatic deletion (default: 90) # Set to nil to keep errors forever (not recommended for production) # Schedule cleanup: RailsErrorDashboard::RetentionCleanupJob.perform_later @retention_days = 90 @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"] # Issue tracker integration defaults — OFF by default, one switch enables all @enable_issue_tracking = false @issue_tracker_token = ENV["RED_BOT_TOKEN"] || ENV["ISSUE_TRACKER_TOKEN"] @issue_tracker_provider = nil # Auto-detect from git_repository_url @issue_tracker_repo = nil # Auto-extract from git_repository_url @issue_tracker_labels = [ "bug" ] @issue_tracker_api_url = nil # For self-hosted instances @issue_tracker_auto_create_severities = [ :critical, :high ] @issue_webhook_secret = ENV["ISSUE_WEBHOOK_SECRET"] # 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 # Breadcrumbs defaults - OFF by default (opt-in) @enable_breadcrumbs = false # Master switch @breadcrumb_buffer_size = 40 # Max events per request (Sentry uses 100, we're conservative) @breadcrumb_categories = nil # nil = all; or [:sql, :controller, :cache, :job, :mailer, :custom, :deprecation] # N+1 query detection defaults - ON by default (lightweight display-time analysis) @enable_n_plus_one_detection = true # Analyze SQL breadcrumbs for repeated patterns @n_plus_one_threshold = 3 # Flag when same query shape appears 3+ times # System health snapshot defaults - OFF by default (opt-in) @enable_system_health = false # Capture GC, memory, threads, connection pool at error time # Local variable capture defaults - OFF by default (opt-in) @enable_local_variables = false # TracePoint(:raise) for local var capture @local_variable_max_count = 15 # Max variables per exception @local_variable_max_depth = 3 # Max nesting depth for objects @local_variable_max_string_length = 200 # Truncate strings beyond this @local_variable_max_array_items = 10 # Max array items to serialize @local_variable_max_hash_items = 20 # Max hash entries to serialize @local_variable_filter_patterns = [] # Additional sensitive variable name patterns # Instance variable capture defaults - OFF by default (opt-in) @enable_instance_variables = false # Capture ivars from tp.self at raise time @instance_variable_max_count = 20 # Max ivars per exception @instance_variable_filter_patterns = [] # Additional sensitive ivar name patterns # Swallowed exception detection defaults - OFF by default (Ruby 3.3+ opt-in) @detect_swallowed_exceptions = false # TracePoint(:raise) + TracePoint(:rescue) @swallowed_exception_max_cache_size = 1000 # Max entries per thread-local hash @swallowed_exception_flush_interval = 60 # Seconds between DB flushes @swallowed_exception_threshold = 0.95 # Rescue ratio to flag as swallowed @swallowed_exception_ignore_classes = [] # Additional exception classes to skip # Process crash capture defaults - OFF by default (opt-in) @enable_crash_capture = false # at_exit hook for fatal crash capture @crash_capture_path = nil # nil = Dir.tmpdir # Diagnostic dump defaults - OFF by default (opt-in) @enable_diagnostic_dump = false # On-demand system state snapshot # Code path coverage defaults - OFF by default (opt-in, Ruby 3.2+) @enable_coverage_tracking = false # Rack Attack event tracking defaults - OFF by default (opt-in, requires breadcrumbs) @enable_rack_attack_tracking = false # ActionCable event tracking defaults - OFF by default (opt-in, requires breadcrumbs) @enable_actioncable_tracking = false # ActiveStorage event tracking defaults - OFF by default (opt-in, requires breadcrumbs) @enable_activestorage_tracking = false # 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
82 83 84 |
# File 'lib/rails_error_dashboard/configuration.rb', line 82 def app_version @app_version end |
#application_name ⇒ Object
Multi-app support - Application name
14 15 16 |
# File 'lib/rails_error_dashboard/configuration.rb', line 14 def application_name @application_name end |
#async_adapter ⇒ Object
:sidekiq, :solid_queue, or :async
72 73 74 |
# File 'lib/rails_error_dashboard/configuration.rb', line 72 def async_adapter @async_adapter end |
#async_logging ⇒ Object
Async logging configuration
71 72 73 |
# File 'lib/rails_error_dashboard/configuration.rb', line 71 def async_logging @async_logging end |
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
8 9 10 |
# File 'lib/rails_error_dashboard/configuration.rb', line 8 def authenticate_with @authenticate_with end |
#baseline_alert_cooldown_minutes ⇒ Object
Minutes between alerts for same error type (default: 120)
114 115 116 |
# File 'lib/rails_error_dashboard/configuration.rb', line 114 def baseline_alert_cooldown_minutes @baseline_alert_cooldown_minutes end |
#baseline_alert_severities ⇒ Object
Array of severities to alert on (default: [:critical, :high])
113 114 115 |
# File 'lib/rails_error_dashboard/configuration.rb', line 113 def baseline_alert_severities @baseline_alert_severities end |
#baseline_alert_threshold_std_devs ⇒ Object
Number of std devs to trigger alert (default: 2.0)
112 113 114 |
# File 'lib/rails_error_dashboard/configuration.rb', line 112 def baseline_alert_threshold_std_devs @baseline_alert_threshold_std_devs end |
#breadcrumb_buffer_size ⇒ Object
Max breadcrumbs per request (default: 40)
138 139 140 |
# File 'lib/rails_error_dashboard/configuration.rb', line 138 def @breadcrumb_buffer_size end |
#breadcrumb_categories ⇒ Object
Which categories to capture (default: nil = all)
139 140 141 |
# File 'lib/rails_error_dashboard/configuration.rb', line 139 def @breadcrumb_categories end |
#crash_capture_path ⇒ Object
Directory for crash files (default: Dir.tmpdir)
171 172 173 |
# File 'lib/rails_error_dashboard/configuration.rb', line 171 def crash_capture_path @crash_capture_path end |
#custom_fingerprint ⇒ Object
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” }
65 66 67 |
# File 'lib/rails_error_dashboard/configuration.rb', line 65 def custom_fingerprint @custom_fingerprint end |
#custom_severity_rules ⇒ Object
Advanced configuration options Custom severity classification rules (hash of error_type => severity)
56 57 58 |
# File 'lib/rails_error_dashboard/configuration.rb', line 56 def custom_severity_rules @custom_severity_rules end |
#dashboard_base_url ⇒ Object
Returns the value of attribute dashboard_base_url.
21 22 23 |
# File 'lib/rails_error_dashboard/configuration.rb', line 21 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
15 16 17 |
# File 'lib/rails_error_dashboard/configuration.rb', line 15 def database @database end |
#detect_swallowed_exceptions ⇒ Object
Swallowed exception detection via TracePoint(:raise) + TracePoint(:rescue) (Ruby 3.3+ only)
163 164 165 |
# File 'lib/rails_error_dashboard/configuration.rb', line 163 def detect_swallowed_exceptions @detect_swallowed_exceptions end |
#digest_frequency ⇒ Object
:daily or :weekly (default: :daily)
39 40 41 |
# File 'lib/rails_error_dashboard/configuration.rb', line 39 def digest_frequency @digest_frequency end |
#digest_recipients ⇒ Object
Array of emails (default: notification_email_recipients)
40 41 42 |
# File 'lib/rails_error_dashboard/configuration.rb', line 40 def digest_recipients @digest_recipients end |
#discord_webhook_url ⇒ Object
Discord notifications
26 27 28 |
# File 'lib/rails_error_dashboard/configuration.rb', line 26 def discord_webhook_url @discord_webhook_url end |
#enable_actioncable_tracking ⇒ Object
ActionCable event tracking (requires enable_breadcrumbs = true)
183 184 185 |
# File 'lib/rails_error_dashboard/configuration.rb', line 183 def enable_actioncable_tracking @enable_actioncable_tracking end |
#enable_activestorage_tracking ⇒ Object
ActiveStorage event tracking (requires enable_breadcrumbs = true)
185 186 187 |
# File 'lib/rails_error_dashboard/configuration.rb', line 185 def enable_activestorage_tracking @enable_activestorage_tracking end |
#enable_baseline_alerts ⇒ Object
Baseline alert configuration
111 112 113 |
# File 'lib/rails_error_dashboard/configuration.rb', line 111 def enable_baseline_alerts @enable_baseline_alerts end |
#enable_breadcrumbs ⇒ Object
Breadcrumbs (request activity trail)
137 138 139 |
# File 'lib/rails_error_dashboard/configuration.rb', line 137 def @enable_breadcrumbs end |
#enable_co_occurring_errors ⇒ Object
Detect errors happening together
104 105 106 |
# File 'lib/rails_error_dashboard/configuration.rb', line 104 def enable_co_occurring_errors @enable_co_occurring_errors end |
#enable_coverage_tracking ⇒ Object
Code path coverage (diagnostic mode — Ruby 3.2+)
177 178 179 |
# File 'lib/rails_error_dashboard/configuration.rb', line 177 def enable_coverage_tracking @enable_coverage_tracking end |
#enable_crash_capture ⇒ Object
Process crash capture via at_exit hook
170 171 172 |
# File 'lib/rails_error_dashboard/configuration.rb', line 170 def enable_crash_capture @enable_crash_capture end |
#enable_diagnostic_dump ⇒ Object
On-demand diagnostic dump (rake task + dashboard endpoint)
174 175 176 |
# File 'lib/rails_error_dashboard/configuration.rb', line 174 def enable_diagnostic_dump @enable_diagnostic_dump end |
#enable_discord_notifications ⇒ Object
Returns the value of attribute enable_discord_notifications.
27 28 29 |
# File 'lib/rails_error_dashboard/configuration.rb', line 27 def enable_discord_notifications @enable_discord_notifications end |
#enable_email_notifications ⇒ Object
Returns the value of attribute enable_email_notifications.
23 24 25 |
# File 'lib/rails_error_dashboard/configuration.rb', line 23 def enable_email_notifications @enable_email_notifications end |
#enable_error_cascades ⇒ Object
Parent→child error relationships
105 106 107 |
# File 'lib/rails_error_dashboard/configuration.rb', line 105 def enable_error_cascades @enable_error_cascades end |
#enable_error_correlation ⇒ Object
Version/user/time correlation
106 107 108 |
# File 'lib/rails_error_dashboard/configuration.rb', line 106 def enable_error_correlation @enable_error_correlation end |
#enable_error_subscriber ⇒ Object
Enable/disable Rails.error subscriber
52 53 54 |
# File 'lib/rails_error_dashboard/configuration.rb', line 52 def enable_error_subscriber @enable_error_subscriber end |
#enable_git_blame ⇒ Object
Show git blame (default: false)
119 120 121 |
# File 'lib/rails_error_dashboard/configuration.rb', line 119 def enable_git_blame @enable_git_blame end |
#enable_instance_variables ⇒ Object
Instance variable capture from tp.self (receiver object at raise time)
158 159 160 |
# File 'lib/rails_error_dashboard/configuration.rb', line 158 def enable_instance_variables @enable_instance_variables end |
#enable_internal_logging ⇒ Object
Internal logging configuration
191 192 193 |
# File 'lib/rails_error_dashboard/configuration.rb', line 191 def enable_internal_logging @enable_internal_logging end |
#enable_issue_tracking ⇒ Object
Issue tracker integration (GitHub, GitLab, Codeberg/Gitea/Forgejo) One switch enables everything: issue creation, auto-create, lifecycle sync, platform state mirroring, and comment display. Webhooks activate when issue_webhook_secret is set.
93 94 95 |
# File 'lib/rails_error_dashboard/configuration.rb', line 93 def enable_issue_tracking @enable_issue_tracking end |
#enable_local_variables ⇒ Object
Local variable capture via TracePoint(:raise)
149 150 151 |
# File 'lib/rails_error_dashboard/configuration.rb', line 149 def enable_local_variables @enable_local_variables end |
#enable_middleware ⇒ Object
Enable/disable error catching middleware
49 50 51 |
# File 'lib/rails_error_dashboard/configuration.rb', line 49 def enable_middleware @enable_middleware end |
#enable_n_plus_one_detection ⇒ Object
N+1 query detection (display-time analysis of SQL breadcrumbs)
142 143 144 |
# File 'lib/rails_error_dashboard/configuration.rb', line 142 def enable_n_plus_one_detection @enable_n_plus_one_detection end |
#enable_occurrence_patterns ⇒ Object
Cyclical/burst pattern detection
108 109 110 |
# File 'lib/rails_error_dashboard/configuration.rb', line 108 def enable_occurrence_patterns @enable_occurrence_patterns end |
#enable_pagerduty_notifications ⇒ Object
Returns the value of attribute enable_pagerduty_notifications.
31 32 33 |
# File 'lib/rails_error_dashboard/configuration.rb', line 31 def enable_pagerduty_notifications @enable_pagerduty_notifications end |
#enable_platform_comparison ⇒ Object
iOS vs Android analytics
107 108 109 |
# File 'lib/rails_error_dashboard/configuration.rb', line 107 def enable_platform_comparison @enable_platform_comparison end |
#enable_rack_attack_tracking ⇒ Object
Rack Attack event tracking (requires enable_breadcrumbs = true)
180 181 182 |
# File 'lib/rails_error_dashboard/configuration.rb', line 180 def enable_rack_attack_tracking @enable_rack_attack_tracking end |
#enable_rate_limiting ⇒ Object
Rate limiting configuration
78 79 80 |
# File 'lib/rails_error_dashboard/configuration.rb', line 78 def enable_rate_limiting @enable_rate_limiting end |
#enable_scheduled_digests ⇒ Object
Scheduled digests (daily/weekly summary emails)
38 39 40 |
# File 'lib/rails_error_dashboard/configuration.rb', line 38 def enable_scheduled_digests @enable_scheduled_digests end |
#enable_similar_errors ⇒ Object
Advanced error analysis features
103 104 105 |
# File 'lib/rails_error_dashboard/configuration.rb', line 103 def enable_similar_errors @enable_similar_errors end |
#enable_slack_notifications ⇒ Object
Returns the value of attribute enable_slack_notifications.
22 23 24 |
# File 'lib/rails_error_dashboard/configuration.rb', line 22 def enable_slack_notifications @enable_slack_notifications end |
#enable_source_code_integration ⇒ Object
Source code integration (show code in backtrace)
117 118 119 |
# File 'lib/rails_error_dashboard/configuration.rb', line 117 def enable_source_code_integration @enable_source_code_integration end |
#enable_system_health ⇒ Object
System health snapshot (GC, memory, threads, connection pool at error time)
146 147 148 |
# File 'lib/rails_error_dashboard/configuration.rb', line 146 def enable_system_health @enable_system_health end |
#enable_webhook_notifications ⇒ Object
Returns the value of attribute enable_webhook_notifications.
35 36 37 |
# File 'lib/rails_error_dashboard/configuration.rb', line 35 def enable_webhook_notifications @enable_webhook_notifications end |
#filter_sensitive_data ⇒ Object
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).
128 129 130 |
# File 'lib/rails_error_dashboard/configuration.rb', line 128 def filter_sensitive_data @filter_sensitive_data end |
#git_branch_strategy ⇒ Object
:commit_sha, :current_branch, :main (default: :commit_sha)
122 123 124 |
# File 'lib/rails_error_dashboard/configuration.rb', line 122 def git_branch_strategy @git_branch_strategy end |
#git_repository_url ⇒ Object
Git repository URL for linking commits (e.g., “github.com/user/repo”)
87 88 89 |
# File 'lib/rails_error_dashboard/configuration.rb', line 87 def git_repository_url @git_repository_url end |
#git_sha ⇒ Object
Returns the value of attribute git_sha.
83 84 85 |
# File 'lib/rails_error_dashboard/configuration.rb', line 83 def git_sha @git_sha end |
#ignored_exceptions ⇒ Object
Exceptions to ignore (array of strings, regexes, or classes)
59 60 61 |
# File 'lib/rails_error_dashboard/configuration.rb', line 59 def ignored_exceptions @ignored_exceptions end |
#instance_variable_filter_patterns ⇒ Object
Additional sensitive ivar patterns (default: [])
160 161 162 |
# File 'lib/rails_error_dashboard/configuration.rb', line 160 def instance_variable_filter_patterns @instance_variable_filter_patterns end |
#instance_variable_max_count ⇒ Object
Max ivars to capture (default: 20)
159 160 161 |
# File 'lib/rails_error_dashboard/configuration.rb', line 159 def instance_variable_max_count @instance_variable_max_count end |
#issue_tracker_api_url ⇒ Object
Custom API base URL for self-hosted instances
98 99 100 |
# File 'lib/rails_error_dashboard/configuration.rb', line 98 def issue_tracker_api_url @issue_tracker_api_url end |
#issue_tracker_auto_create_severities ⇒ Object
Auto-create for these severities (default: [:critical, :high])
99 100 101 |
# File 'lib/rails_error_dashboard/configuration.rb', line 99 def issue_tracker_auto_create_severities @issue_tracker_auto_create_severities end |
#issue_tracker_labels ⇒ Object
Array of label strings (default: [“bug”])
97 98 99 |
# File 'lib/rails_error_dashboard/configuration.rb', line 97 def issue_tracker_labels @issue_tracker_labels end |
#issue_tracker_provider ⇒ Object
:github, :gitlab, :codeberg (auto-detected from git_repository_url)
95 96 97 |
# File 'lib/rails_error_dashboard/configuration.rb', line 95 def issue_tracker_provider @issue_tracker_provider end |
#issue_tracker_repo ⇒ Object
“owner/repo” (auto-extracted from git_repository_url)
96 97 98 |
# File 'lib/rails_error_dashboard/configuration.rb', line 96 def issue_tracker_repo @issue_tracker_repo end |
#issue_tracker_token ⇒ Object
String or lambda/proc for Rails credentials
94 95 96 |
# File 'lib/rails_error_dashboard/configuration.rb', line 94 def issue_tracker_token @issue_tracker_token end |
#issue_webhook_secret ⇒ Object
HMAC secret — webhooks activate when this is set
100 101 102 |
# File 'lib/rails_error_dashboard/configuration.rb', line 100 def issue_webhook_secret @issue_webhook_secret end |
#local_variable_filter_patterns ⇒ Object
Additional sensitive name patterns (default: [])
155 156 157 |
# File 'lib/rails_error_dashboard/configuration.rb', line 155 def local_variable_filter_patterns @local_variable_filter_patterns end |
#local_variable_max_array_items ⇒ Object
Max array items to serialize (default: 10)
153 154 155 |
# File 'lib/rails_error_dashboard/configuration.rb', line 153 def local_variable_max_array_items @local_variable_max_array_items end |
#local_variable_max_count ⇒ Object
Max variables to capture (default: 15)
150 151 152 |
# File 'lib/rails_error_dashboard/configuration.rb', line 150 def local_variable_max_count @local_variable_max_count end |
#local_variable_max_depth ⇒ Object
Max object nesting depth (default: 3)
151 152 153 |
# File 'lib/rails_error_dashboard/configuration.rb', line 151 def local_variable_max_depth @local_variable_max_depth end |
#local_variable_max_hash_items ⇒ Object
Max hash entries to serialize (default: 20)
154 155 156 |
# File 'lib/rails_error_dashboard/configuration.rb', line 154 def local_variable_max_hash_items @local_variable_max_hash_items end |
#local_variable_max_string_length ⇒ Object
Max string value length (default: 200)
152 153 154 |
# File 'lib/rails_error_dashboard/configuration.rb', line 152 def local_variable_max_string_length @local_variable_max_string_length end |
#log_level ⇒ Object
Returns the value of attribute log_level.
192 193 194 |
# File 'lib/rails_error_dashboard/configuration.rb', line 192 def log_level @log_level end |
#max_backtrace_lines ⇒ Object
Backtrace configuration
75 76 77 |
# File 'lib/rails_error_dashboard/configuration.rb', line 75 def max_backtrace_lines @max_backtrace_lines end |
#n_plus_one_threshold ⇒ Object
Min repetitions to flag (default: 3, min: 2)
143 144 145 |
# File 'lib/rails_error_dashboard/configuration.rb', line 143 def n_plus_one_threshold @n_plus_one_threshold end |
#notification_callbacks ⇒ Object (readonly)
Notification callbacks (managed via helper methods, not set directly)
188 189 190 |
# File 'lib/rails_error_dashboard/configuration.rb', line 188 def notification_callbacks @notification_callbacks end |
#notification_cooldown_minutes ⇒ Object
Per-error cooldown in minutes (default: 5, 0 = disabled)
133 134 135 |
# File 'lib/rails_error_dashboard/configuration.rb', line 133 def notification_cooldown_minutes @notification_cooldown_minutes end |
#notification_email_from ⇒ Object
Returns the value of attribute notification_email_from.
20 21 22 |
# File 'lib/rails_error_dashboard/configuration.rb', line 20 def notification_email_from @notification_email_from end |
#notification_email_recipients ⇒ Object
Returns the value of attribute notification_email_recipients.
19 20 21 |
# File 'lib/rails_error_dashboard/configuration.rb', line 19 def notification_email_recipients @notification_email_recipients end |
#notification_minimum_severity ⇒ Object
Notification throttling (prevents alert fatigue)
132 133 134 |
# File 'lib/rails_error_dashboard/configuration.rb', line 132 def notification_minimum_severity @notification_minimum_severity end |
#notification_threshold_alerts ⇒ Object
Occurrence milestones that trigger notification (default: [10, 50, 100, 500, 1000])
134 135 136 |
# File 'lib/rails_error_dashboard/configuration.rb', line 134 def notification_threshold_alerts @notification_threshold_alerts end |
#only_show_app_code_source ⇒ Object
Hide gems/stdlib (default: true)
121 122 123 |
# File 'lib/rails_error_dashboard/configuration.rb', line 121 def only_show_app_code_source @only_show_app_code_source end |
#pagerduty_integration_key ⇒ Object
PagerDuty notifications (critical errors only)
30 31 32 |
# File 'lib/rails_error_dashboard/configuration.rb', line 30 def pagerduty_integration_key @pagerduty_integration_key end |
#rate_limit_per_minute ⇒ Object
Returns the value of attribute rate_limit_per_minute.
79 80 81 |
# File 'lib/rails_error_dashboard/configuration.rb', line 79 def rate_limit_per_minute @rate_limit_per_minute end |
#retention_days ⇒ Object
Retention policy (days to keep errors)
46 47 48 |
# File 'lib/rails_error_dashboard/configuration.rb', line 46 def retention_days @retention_days end |
#sampling_rate ⇒ Object
Sampling rate for non-critical errors (0.0 to 1.0, default 1.0 = 100%)
68 69 70 |
# File 'lib/rails_error_dashboard/configuration.rb', line 68 def sampling_rate @sampling_rate end |
#sensitive_data_patterns ⇒ Object
Additional patterns beyond Rails’ filter_parameters
129 130 131 |
# File 'lib/rails_error_dashboard/configuration.rb', line 129 def sensitive_data_patterns @sensitive_data_patterns end |
#slack_webhook_url ⇒ Object
Notifications
18 19 20 |
# File 'lib/rails_error_dashboard/configuration.rb', line 18 def slack_webhook_url @slack_webhook_url end |
#source_code_cache_ttl ⇒ Object
Cache TTL in seconds (default: 3600)
120 121 122 |
# File 'lib/rails_error_dashboard/configuration.rb', line 120 def source_code_cache_ttl @source_code_cache_ttl end |
#source_code_context_lines ⇒ Object
Lines before/after (default: 5)
118 119 120 |
# File 'lib/rails_error_dashboard/configuration.rb', line 118 def source_code_context_lines @source_code_context_lines end |
#swallowed_exception_flush_interval ⇒ Object
Seconds between flushes (default: 60)
165 166 167 |
# File 'lib/rails_error_dashboard/configuration.rb', line 165 def swallowed_exception_flush_interval @swallowed_exception_flush_interval end |
#swallowed_exception_ignore_classes ⇒ Object
Additional exception classes to skip (default: [])
167 168 169 |
# File 'lib/rails_error_dashboard/configuration.rb', line 167 def swallowed_exception_ignore_classes @swallowed_exception_ignore_classes end |
#swallowed_exception_max_cache_size ⇒ Object
Max entries per thread (default: 1000)
164 165 166 |
# File 'lib/rails_error_dashboard/configuration.rb', line 164 def swallowed_exception_max_cache_size @swallowed_exception_max_cache_size end |
#swallowed_exception_threshold ⇒ Object
Rescue ratio to flag (default: 0.95)
166 167 168 |
# File 'lib/rails_error_dashboard/configuration.rb', line 166 def swallowed_exception_threshold @swallowed_exception_threshold end |
#total_users_for_impact ⇒ Object
For user impact % calculation
84 85 86 |
# File 'lib/rails_error_dashboard/configuration.rb', line 84 def total_users_for_impact @total_users_for_impact end |
#use_separate_database ⇒ Object
Separate database configuration
43 44 45 |
# File 'lib/rails_error_dashboard/configuration.rb', line 43 def use_separate_database @use_separate_database end |
#user_model ⇒ Object
User model (for associations)
11 12 13 |
# File 'lib/rails_error_dashboard/configuration.rb', line 11 def user_model @user_model end |
#webhook_urls ⇒ Object
Generic webhook notifications
34 35 36 |
# File 'lib/rails_error_dashboard/configuration.rb', line 34 def webhook_urls @webhook_urls end |
Instance Method Details
#clear_total_users_cache! ⇒ Object
Clear the total users cache
725 726 727 |
# File 'lib/rails_error_dashboard/configuration.rb', line 725 def clear_total_users_cache! @total_users_cache = {} end |
#default_credentials? ⇒ Boolean
Check if using default or blank demo credentials with basic auth
Returns false if the user explicitly set ENV vars (even to the same default values), because that’s a deliberate choice. Only blocks when credentials are untouched defaults or blank.
621 622 623 624 625 626 627 628 629 630 631 |
# File 'lib/rails_error_dashboard/configuration.rb', line 621 def default_credentials? return false unless authenticate_with.nil? # If user explicitly set ENV vars, respect their choice return false if ENV.key?("ERROR_DASHBOARD_USER") || ENV.key?("ERROR_DASHBOARD_PASSWORD") default = dashboard_username == "gandalf" && dashboard_password == "youshallnotpass" blank = dashboard_username.to_s.strip.empty? || dashboard_password.to_s.strip.empty? default || blank end |
#detect_engine_mount_path ⇒ String
Detect where the engine is mounted in the host app’s routes.
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/rails_error_dashboard/configuration.rb', line 731 def detect_engine_mount_path return "/red" unless defined?(Rails) && Rails.application Rails.application.routes.routes.each do |route| app = route.app app = app.app if app.respond_to?(:app) if app == RailsErrorDashboard::Engine || (app.is_a?(Class) && app <= RailsErrorDashboard::Engine) path = route.path.spec.to_s.sub("(.:format)", "").chomp("/") return path if path.present? end rescue => e next end "/red" rescue => e "/red" end |
#effective_issue_tracker_api_url ⇒ String
Resolve the effective API base URL for the issue tracker
673 674 675 676 677 678 679 680 681 |
# File 'lib/rails_error_dashboard/configuration.rb', line 673 def effective_issue_tracker_api_url return issue_tracker_api_url if issue_tracker_api_url.present? case effective_issue_tracker_provider when :github then "https://api.github.com" when :gitlab then "https://gitlab.com/api/v4" when :codeberg then "https://codeberg.org/api/v1" end end |
#effective_issue_tracker_provider ⇒ Symbol?
Resolve the effective issue tracker provider (auto-detect from git_repository_url)
636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/rails_error_dashboard/configuration.rb', line 636 def effective_issue_tracker_provider return issue_tracker_provider&.to_sym if issue_tracker_provider.present? return nil if git_repository_url.blank? case git_repository_url when /github\.com/i then :github when /gitlab\.com/i then :gitlab when /codeberg\.org/i then :codeberg when /gitea\./i, /forgejo\./i then :codeberg # Gitea/Forgejo instances use same API end end |
#effective_issue_tracker_repo ⇒ String?
Resolve the effective issue tracker repository (“owner/repo”)
651 652 653 654 655 656 657 658 |
# File 'lib/rails_error_dashboard/configuration.rb', line 651 def effective_issue_tracker_repo return issue_tracker_repo if issue_tracker_repo.present? return nil if git_repository_url.blank? # Extract owner/repo from URL: https://github.com/owner/repo(.git) match = git_repository_url.match(%r{[:/]([^/]+/[^/]+?)(?:\.git)?$}) match&.[](1) end |
#effective_issue_tracker_token ⇒ String?
Resolve the issue tracker API token (supports string or lambda)
663 664 665 666 667 668 |
# File 'lib/rails_error_dashboard/configuration.rb', line 663 def effective_issue_tracker_token return nil if issue_tracker_token.nil? issue_tracker_token.respond_to?(:call) ? issue_tracker_token.call : issue_tracker_token rescue => e nil 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
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/rails_error_dashboard/configuration.rb', line 704 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)
694 695 696 697 698 |
# File 'lib/rails_error_dashboard/configuration.rb', line 694 def effective_user_model return @user_model if @user_model.present? RailsErrorDashboard::Helpers::UserModelDetector.detect_user_model end |
#engine_mount_path ⇒ String
Detect the engine’s mount path from the host app routes. Falls back to “/red” if detection fails.
687 688 689 |
# File 'lib/rails_error_dashboard/configuration.rb', line 687 def engine_mount_path @engine_mount_path ||= detect_engine_mount_path end |
#reset! ⇒ Object
Reset configuration to defaults
364 365 366 |
# File 'lib/rails_error_dashboard/configuration.rb', line 364 def reset! initialize end |
#validate! ⇒ true
Validate configuration values Raises ConfigurationError if any validation fails Logs warnings for non-fatal issues (e.g., Ruby version incompatibilities)
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/rails_error_dashboard/configuration.rb', line 374 def validate! errors = [] warnings = [] # Block boot with default or blank credentials in production # Skip during asset precompilation (SECRET_KEY_BASE_DUMMY=1) — ENV vars aren't available at build time if default_credentials? && defined?(Rails) && Rails.respond_to?(:env) && Rails.env.production? && ENV["SECRET_KEY_BASE_DUMMY"].blank? errors << "Default or blank credentials cannot be used in production. Set ERROR_DASHBOARD_USER and ERROR_DASHBOARD_PASSWORD environment variables, or use authenticate_with for custom auth." end # 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 authenticate_with (must respond to .call if set) if authenticate_with && !authenticate_with.respond_to?(:call) errors << "authenticate_with must respond to .call (lambda, proc, or object with .call method)" end # Validate breadcrumb_buffer_size (must be positive if breadcrumbs enabled) if && && < 1 errors << "breadcrumb_buffer_size must be at least 1 (got: #{})" end # Validate n_plus_one_threshold (must be at least 2 if detection enabled) if enable_n_plus_one_detection && n_plus_one_threshold && n_plus_one_threshold < 2 errors << "n_plus_one_threshold must be at least 2 (got: #{n_plus_one_threshold})" end # Validate local variable capture settings if enable_local_variables if local_variable_max_count && local_variable_max_count < 1 errors << "local_variable_max_count must be at least 1 (got: #{local_variable_max_count})" end if local_variable_max_depth && local_variable_max_depth < 1 errors << "local_variable_max_depth must be at least 1 (got: #{local_variable_max_depth})" end if local_variable_max_string_length && local_variable_max_string_length < 1 errors << "local_variable_max_string_length must be at least 1 (got: #{local_variable_max_string_length})" end end # Validate instance variable capture settings if enable_instance_variables && instance_variable_max_count && instance_variable_max_count < 1 errors << "instance_variable_max_count must be at least 1 (got: #{instance_variable_max_count})" end # Validate swallowed exception detection settings # Auto-disable on Ruby < 3.3 (warn, don't crash) if detect_swallowed_exceptions && RUBY_VERSION < "3.3" warnings << "detect_swallowed_exceptions requires Ruby 3.3+ (current: #{RUBY_VERSION}). " \ "TracePoint(:rescue) was added in Ruby 3.3 (Feature #19572). " \ "Feature has been auto-disabled. Upgrade Ruby to use this feature." @detect_swallowed_exceptions = false end # Validate sub-settings only if feature is still active after version check if detect_swallowed_exceptions if swallowed_exception_max_cache_size && swallowed_exception_max_cache_size < 1 errors << "swallowed_exception_max_cache_size must be at least 1 (got: #{swallowed_exception_max_cache_size})" end if swallowed_exception_flush_interval && swallowed_exception_flush_interval < 1 errors << "swallowed_exception_flush_interval must be at least 1 (got: #{swallowed_exception_flush_interval})" end if swallowed_exception_threshold && (swallowed_exception_threshold < 0.0 || swallowed_exception_threshold > 1.0) errors << "swallowed_exception_threshold must be between 0.0 and 1.0 (got: #{swallowed_exception_threshold})" end end # Validate rack_attack tracking requires breadcrumbs if enable_rack_attack_tracking && ! warnings << "enable_rack_attack_tracking requires enable_breadcrumbs = true. " \ "Rack Attack tracking has been auto-disabled." @enable_rack_attack_tracking = false end # Validate actioncable tracking requires breadcrumbs if enable_actioncable_tracking && ! warnings << "enable_actioncable_tracking requires enable_breadcrumbs = true. " \ "ActionCable tracking has been auto-disabled." @enable_actioncable_tracking = false end # Validate activestorage tracking requires breadcrumbs if enable_activestorage_tracking && ! warnings << "enable_activestorage_tracking requires enable_breadcrumbs = true. " \ "ActiveStorage tracking has been auto-disabled." @enable_activestorage_tracking = false end # Skip credential/service-dependent validations during Docker builds. # SECRET_KEY_BASE_DUMMY=1 means no credentials or external services available. build_env = ENV["SECRET_KEY_BASE_DUMMY"].present? # Validate issue tracking configuration unless build_env if enable_issue_tracking && effective_issue_tracker_token.blank? warnings << "enable_issue_tracking is true but no token configured. " \ "Set issue_tracker_token or RED_BOT_TOKEN env var. " \ "Tip: Create a dedicated RED (Rails Error Dashboard) bot account on your platform." end if enable_issue_tracking && effective_issue_tracker_provider.nil? warnings << "enable_issue_tracking is true but provider could not be detected. " \ "Set issue_tracker_provider or git_repository_url." end end # Validate crash capture path — auto-create if missing if enable_crash_capture && crash_capture_path && !build_env unless Dir.exist?(crash_capture_path) begin FileUtils.mkdir_p(crash_capture_path) rescue => e errors << "crash_capture_path '#{crash_capture_path}' could not be created: #{e.}" end end end # Validate notification dependencies (skip during builds — credentials unavailable) unless build_env 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 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 # Log warnings (non-fatal issues) warnings.each do |warning| Rails.logger.warn "[Rails Error Dashboard] #{warning}" if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger end # Raise exception if any errors found raise ConfigurationError, errors if errors.any? true end |