Class: SpreeMenuChat::Alerting

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_menu_chat/alerting.rb

Overview

One place for "this needs a human" — used when a job exhausts its retries. A standalone copy of SpreeSquare::Alerting's / SpreeDoordash:: Alerting's identical pattern rather than a dependency on either gem — spree_menu_chat stays independently installable on its own. Reports to Sentry when available, always logs at error level regardless so nothing depends on Sentry being configured to at least be visible in the server log.

Class Method Summary collapse

Class Method Details

.capture(error, context: {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/services/spree_menu_chat/alerting.rb', line 10

def self.capture(error, context: {})
  context = { source: 'spree_menu_chat' }.merge(context.is_a?(String) ? { area: context } : context)

  Rails.logger.error("[SpreeMenuChat] #{context[:area] || 'error'}: #{error.class}: #{error.message}")

  return unless defined?(Sentry)

  Sentry.capture_exception(error, extra: context)
end