Class: RailsErrorDashboard::WebhookErrorNotificationJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/rails_error_dashboard/webhook_error_notification_job.rb

Overview

Job to send error notifications to custom webhook URLs Supports multiple webhooks for different integrations

Instance Method Summary collapse

Instance Method Details

#perform(error_log_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/jobs/rails_error_dashboard/webhook_error_notification_job.rb', line 11

def perform(error_log_id)
  error_log = ErrorLog.find(error_log_id)
  webhook_urls = RailsErrorDashboard.configuration.webhook_urls

  return unless webhook_urls.present?

  # Ensure webhook_urls is an array
  urls = Array(webhook_urls)

  payload = build_webhook_payload(error_log)

  urls.each do |url|
    send_webhook(url, payload, error_log)
  end
rescue StandardError => e
  Rails.logger.error("[RailsErrorDashboard] Failed to send webhook notification: #{e.message}")
  Rails.logger.error(e.backtrace&.first(5)&.join("\n")) if e.backtrace
end