Class: AnalyticsPSW::MockAnalytics
- Inherits:
-
Object
- Object
- AnalyticsPSW::MockAnalytics
- Defined in:
- lib/analytics-psw.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#event_types ⇒ Object
Returns the value of attribute event_types.
Instance Method Summary collapse
- #debug(msg) ⇒ Object
-
#initialize(opts = {}) ⇒ MockAnalytics
constructor
A new instance of MockAnalytics.
- #record_event(event_type, metadata = {}, asynchronous = false) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ MockAnalytics
Returns a new instance of MockAnalytics.
69 70 71 72 73 |
# File 'lib/analytics-psw.rb', line 69 def initialize(opts = {}) debug("initializing mock Analytics") @event_types = opts['event_types'] || [] @dimensions = opts['dimensions'] ? (opts['dimensions'].map { |hsh| hsh.keys }.flatten) : [] end |
Instance Attribute Details
#dimensions ⇒ Object
Returns the value of attribute dimensions.
67 68 69 |
# File 'lib/analytics-psw.rb', line 67 def dimensions @dimensions end |
#event_types ⇒ Object
Returns the value of attribute event_types.
67 68 69 |
# File 'lib/analytics-psw.rb', line 67 def event_types @event_types end |
Instance Method Details
#debug(msg) ⇒ Object
79 80 81 82 83 |
# File 'lib/analytics-psw.rb', line 79 def debug(msg) return if !defined?(Rails) || Rails.logger.blank? Rails.logger.info("Analytics: " + msg) end |
#record_event(event_type, metadata = {}, asynchronous = false) ⇒ Object
75 76 77 |
# File 'lib/analytics-psw.rb', line 75 def record_event(event_type, = {}, asynchronous = false) debug("record event: #{event_type}, #{.inspect}") end |