Class: Honeybadger::Event
- Inherits:
-
Object
- Object
- Honeybadger::Event
- Extended by:
- Forwardable
- Defined in:
- lib/honeybadger/event.rb
Instance Attribute Summary collapse
-
#event_type ⇒ Object
readonly
The event_type of the event.
-
#payload ⇒ Object
readonly
The payload data of the event.
-
#ts ⇒ Object
readonly
The timestamp of the event.
Instance Method Summary collapse
-
#as_json(*args) ⇒ Hash
private
Template used to create JSON payload.
-
#halt! ⇒ Object
Halts the event and the before_event callback chain.
-
#halted? ⇒ Boolean
private
Determines if this event will be discarded.
-
#initialize(event_type_or_payload, payload = {}) ⇒ Event
constructor
private
A new instance of Event.
Constructor Details
#initialize(event_type_or_payload, payload = {}) ⇒ Event
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Event.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/honeybadger/event.rb', line 21 def initialize(event_type_or_payload, payload={}) if event_type_or_payload.is_a?(String) @event_type = event_type_or_payload @payload = payload elsif event_type_or_payload.is_a?(Hash) @event_type = event_type_or_payload[:event_type] || event_type_or_payload["event_type"] @payload = event_type_or_payload end @ts = payload[:ts] || Time.now.utc.strftime("%FT%T.%LZ") @halted = false end |
Instance Attribute Details
#event_type ⇒ Object (readonly)
The event_type of the event
13 14 15 |
# File 'lib/honeybadger/event.rb', line 13 def event_type @event_type end |
#payload ⇒ Object (readonly)
The payload data of the event
16 17 18 |
# File 'lib/honeybadger/event.rb', line 16 def payload @payload end |
#ts ⇒ Object (readonly)
The timestamp of the event
10 11 12 |
# File 'lib/honeybadger/event.rb', line 10 def ts @ts end |
Instance Method Details
#as_json(*args) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Template used to create JSON payload.
51 52 53 54 55 56 57 |
# File 'lib/honeybadger/event.rb', line 51 def as_json(*args) data = payload.tap do |p| p[:ts] = ts p[:event_type] = event_type if event_type end Util::Sanitizer.sanitize(data) end |
#halt! ⇒ Object
Halts the event and the before_event callback chain.
Returns nothing.
37 38 39 |
# File 'lib/honeybadger/event.rb', line 37 def halt! @halted ||= true end |
#halted? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if this event will be discarded.
43 44 45 |
# File 'lib/honeybadger/event.rb', line 43 def halted? !!@halted end |