Class: Omnitrack::Adapters::Base
- Inherits:
-
Object
- Object
- Omnitrack::Adapters::Base
- Defined in:
- lib/omnitrack/adapters/base.rb
Overview
All platform adapters inherit from this class.
Subclasses MUST implement:
- #track_event(event_name, payload)
- #track_conversion(data)
- #identify_user(user_data)
Subclasses MAY override:
- #enabled? — to add extra guards
- #validate_config — to check required keys
Direct Known Subclasses
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Convenience: register a custom adapter with the dispatcher.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
——————————————————————- Helpers available to subclasses ——————————————————————-.
-
#identify_user(user_data = {}) ⇒ Omnitrack::Result
Identify / associate a user.
-
#initialize(config: {}, logger: nil) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
-
#track_conversion(data = {}) ⇒ Omnitrack::Result
Track a conversion (purchase, lead, etc.).
-
#track_event(event_name, payload = {}) ⇒ Omnitrack::Result
Track a named event.
Constructor Details
Class Attribute Details
.adapter_name ⇒ Object
26 27 28 |
# File 'lib/omnitrack/adapters/base.rb', line 26 def adapter_name @adapter_name || name.to_s.split("::").last.underscore.to_sym end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
37 38 39 |
# File 'lib/omnitrack/adapters/base.rb', line 37 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
37 38 39 |
# File 'lib/omnitrack/adapters/base.rb', line 37 def logger @logger end |
Class Method Details
Instance Method Details
#enabled? ⇒ Boolean
Helpers available to subclasses
75 76 77 |
# File 'lib/omnitrack/adapters/base.rb', line 75 def enabled? config.fetch(:enabled, false) end |
#identify_user(user_data = {}) ⇒ Omnitrack::Result
Identify / associate a user.
67 68 69 |
# File 'lib/omnitrack/adapters/base.rb', line 67 def identify_user(user_data = {}) raise NotImplementedError, "#{self.class}#identify_user not implemented" end |
#name ⇒ Object
79 80 81 |
# File 'lib/omnitrack/adapters/base.rb', line 79 def name self.class.adapter_name end |
#track_conversion(data = {}) ⇒ Omnitrack::Result
Track a conversion (purchase, lead, etc.).
60 61 62 |
# File 'lib/omnitrack/adapters/base.rb', line 60 def track_conversion(data = {}) raise NotImplementedError, "#{self.class}#track_conversion not implemented" end |
#track_event(event_name, payload = {}) ⇒ Omnitrack::Result
Track a named event.
53 54 55 |
# File 'lib/omnitrack/adapters/base.rb', line 53 def track_event(event_name, payload = {}) raise NotImplementedError, "#{self.class}#track_event not implemented" end |