Class: RailsErrorDashboard::DiscordErrorNotificationJob

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

Overview

Job to send error notifications to Discord via webhook

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.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/jobs/rails_error_dashboard/discord_error_notification_job.rb', line 10

def perform(error_log_id, locale = nil)
  error_log = ErrorLog.find(error_log_id)
  webhook_url = RailsErrorDashboard.configuration.discord_webhook_url

  return unless webhook_url.present?

  payload = Services::DiscordPayloadBuilder.call(error_log, locale: job_locale(locale))
  post_json(webhook_url, payload)
rescue StandardError => e
  Rails.logger.error("[RailsErrorDashboard] Failed to send Discord notification: #{e.message}")
  Rails.logger.error(e.backtrace&.first(5)&.join("\n")) if e.backtrace
end