Class: Aptabase::Event
- Inherits:
-
Object
- Object
- Aptabase::Event
- Defined in:
- lib/aptabase/event.rb
Overview
An analytics event queued for delivery to Aptabase.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(name:, timestamp: nil, session_id: nil, props: nil) ⇒ Event
constructor
A new instance of Event.
- #to_h(system_props) ⇒ Object
Constructor Details
#initialize(name:, timestamp: nil, session_id: nil, props: nil) ⇒ Event
Returns a new instance of Event.
11 12 13 14 15 16 |
# File 'lib/aptabase/event.rb', line 11 def initialize(name:, timestamp: nil, session_id: nil, props: nil) @name = name @timestamp = ( || Time.now).utc @session_id = session_id || SecureRandom.uuid @props = props || {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/aptabase/event.rb', line 9 def name @name end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
9 10 11 |
# File 'lib/aptabase/event.rb', line 9 def props @props end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
9 10 11 |
# File 'lib/aptabase/event.rb', line 9 def session_id @session_id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/aptabase/event.rb', line 9 def @timestamp end |
Instance Method Details
#to_h(system_props) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/aptabase/event.rb', line 18 def to_h(system_props) { "timestamp" => .iso8601(3), "sessionId" => session_id, "eventName" => name, "systemProps" => system_props.to_h, "props" => props } end |