Class: RailsErrorDashboard::Services::DiscordPayloadBuilder
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::DiscordPayloadBuilder
- Defined in:
- lib/rails_error_dashboard/services/discord_payload_builder.rb
Overview
Pure algorithm: Build Discord embed payload for error notifications
No HTTP calls — accepts error data, returns a Hash ready for JSON serialization.
Constant Summary collapse
- SEVERITY_COLORS =
{ critical: 16711680, # Red high: 16744192, # Orange medium: 16776960 # Yellow }.freeze
- DEFAULT_COLOR =
Yellow
8421504
Class Method Summary collapse
-
.call(error_log) ⇒ Hash
Discord embed payload.
-
.severity_color(error_log) ⇒ Integer
Discord color integer.
Class Method Details
.call(error_log) ⇒ Hash
Returns Discord embed payload.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rails_error_dashboard/services/discord_payload_builder.rb', line 22 def self.call(error_log) { embeds: [ { title: "🚨 New Error: #{error_log.error_type}", description: NotificationHelpers.(error_log., 200), color: severity_color(error_log), fields: [ { name: "Platform", value: error_log.platform || "Unknown", inline: true }, { name: "Occurrences", value: error_log.occurrence_count.to_s, inline: true }, { name: "Controller", value: error_log.controller_name || "N/A", inline: true }, { name: "Action", value: error_log.action_name || "N/A", inline: true }, { name: "First Seen", value: NotificationHelpers.format_time(error_log.first_seen_at), inline: true }, { name: "Location", value: NotificationHelpers.extract_first_backtrace_line(error_log.backtrace), inline: false } ], footer: { text: "Rails Error Dashboard" }, timestamp: error_log.occurred_at.iso8601 } ] } end |
.severity_color(error_log) ⇒ Integer
Returns Discord color integer.
70 71 72 |
# File 'lib/rails_error_dashboard/services/discord_payload_builder.rb', line 70 def self.severity_color(error_log) SEVERITY_COLORS[error_log.severity] || DEFAULT_COLOR end |