Class: AnalyticsPSW::MockAnalytics

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics-psw.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dimensionsObject

Returns the value of attribute dimensions.



67
68
69
# File 'lib/analytics-psw.rb', line 67

def dimensions
  @dimensions
end

#event_typesObject

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