Class: Webhookdb::DeveloperAlert
- Inherits:
-
Object
- Object
- Webhookdb::DeveloperAlert
- Includes:
- Appydays::Configurable
- Defined in:
- lib/webhookdb/developer_alert.rb
Overview
Decouples the need to alert from the way we want to handle alerts. This is for something in between purely technical alerts (error handling in Sentry) and ops/marketing alerts (which may post to Slack or whatever). Instead of having to rewrite many async jobs to not use Slack, we can just modiy the one job that handles developer alerts.
Instance Attribute Summary collapse
-
#emoji ⇒ Object
Returns the value of attribute emoji.
-
#fallback ⇒ Object
Returns the value of attribute fallback.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#subsystem ⇒ Object
Returns the value of attribute subsystem.
Instance Method Summary collapse
- #as_json ⇒ Object
- #emit ⇒ Object
- #handle ⇒ Object
-
#initialize(subsystem:, emoji:, fallback:, fields:) ⇒ DeveloperAlert
constructor
A new instance of DeveloperAlert.
Constructor Details
#initialize(subsystem:, emoji:, fallback:, fields:) ⇒ DeveloperAlert
Returns a new instance of DeveloperAlert.
16 17 18 19 20 21 |
# File 'lib/webhookdb/developer_alert.rb', line 16 def initialize(subsystem:, emoji:, fallback:, fields:) @subsystem = subsystem @emoji = emoji @fallback = fallback @fields = fields end |
Instance Attribute Details
#emoji ⇒ Object
Returns the value of attribute emoji.
14 15 16 |
# File 'lib/webhookdb/developer_alert.rb', line 14 def emoji @emoji end |
#fallback ⇒ Object
Returns the value of attribute fallback.
14 15 16 |
# File 'lib/webhookdb/developer_alert.rb', line 14 def fallback @fallback end |
#fields ⇒ Object
Returns the value of attribute fields.
14 15 16 |
# File 'lib/webhookdb/developer_alert.rb', line 14 def fields @fields end |
#subsystem ⇒ Object
Returns the value of attribute subsystem.
14 15 16 |
# File 'lib/webhookdb/developer_alert.rb', line 14 def subsystem @subsystem end |
Instance Method Details
#as_json ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/webhookdb/developer_alert.rb', line 23 def as_json return { subsystem:, emoji:, fallback:, fields:, } end |
#emit ⇒ Object
32 33 34 |
# File 'lib/webhookdb/developer_alert.rb', line 32 def emit Amigo.publish("webhookdb.developeralert.emitted", self.as_json) end |
#handle ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/webhookdb/developer_alert.rb', line 36 def handle notifier = Webhookdb::Slack.new_notifier( channel: "#webhookdb-notifications", username: @subsystem, icon_emoji: @emoji, ) notifier.post( attachments: [ { fallback: @fallback, fields: @fields, }, ], ) end |