Class: RailsErrorDashboard::Services::ErrorNotificationDispatcher

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

Overview

Service: Route error notifications to configured channels

Checks configuration and enqueues notification jobs for all enabled channels. Each channel has its own background job for delivery.

Examples:

ErrorNotificationDispatcher.call(error_log)

Class Method Summary collapse

Class Method Details

.call(error_log) ⇒ Object

Parameters:

  • error_log (ErrorLog)

    The error to notify about



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rails_error_dashboard/services/error_notification_dispatcher.rb', line 14

def self.call(error_log)
  config = RailsErrorDashboard.configuration

  if config.enable_slack_notifications && config.slack_webhook_url.present?
    SlackErrorNotificationJob.perform_later(error_log.id)
  end

  if config.enable_email_notifications && config.notification_email_recipients.present?
    EmailErrorNotificationJob.perform_later(error_log.id)
  end

  if config.enable_discord_notifications && config.discord_webhook_url.present?
    DiscordErrorNotificationJob.perform_later(error_log.id)
  end

  if config.enable_pagerduty_notifications && config.pagerduty_integration_key.present?
    PagerdutyErrorNotificationJob.perform_later(error_log.id)
  end

  if config.enable_webhook_notifications && config.webhook_urls.present?
    WebhookErrorNotificationJob.perform_later(error_log.id)
  end
end