Module: Hooksmith::EventRecorder
- Defined in:
- lib/hooksmith/event_recorder.rb
Overview
Records webhook events to a configurable persistence model.
This recorder is resilient: failures to persist are logged and do not impact the main processing flow.
Class Method Summary collapse
-
.record!(provider:, event:, payload:, timing: :before) ⇒ Object
Record an event if the event store is enabled.
Class Method Details
.record!(provider:, event:, payload:, timing: :before) ⇒ Object
Record an event if the event store is enabled.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hooksmith/event_recorder.rb', line 17 def record!(provider:, event:, payload:, timing: :before) config = Hooksmith.configuration.event_store_config return unless config.enabled return unless record_for_timing?(config, timing) model_class = config.model_class unless model_class Hooksmith.logger.warn("Event store enabled but model '#{config.model_class_name}' not found") return end attributes = safe_map(config, provider:, event:, payload:) model_class.create!(attributes) rescue StandardError => e Hooksmith.logger.error("Failed to record webhook event: #{e.message}") end |