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, locale = nil) ⇒ Object

Parameters:

  • locale (String, nil) (defaults to: nil)

    resolved at enqueue time. nil for jobs enqueued by a pre-Phase-4 version still draining from the queue.



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, locale = nil)
  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 = Services::WebhookPayloadBuilder.call(error_log, locale: job_locale(locale))

  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