Class: Ahoy::Stores::LogStore

Inherits:
BaseStore show all
Defined in:
lib/ahoy/stores/log_store.rb

Instance Method Summary collapse

Methods inherited from BaseStore

#authenticate, #exclude?, #generate_id, #initialize, #report_exception, #user, #visit

Constructor Details

This class inherits a constructor from Ahoy::Stores::BaseStore

Instance Method Details

#track_event(name, properties, options) {|data| ... } ⇒ Object

Yields:

  • (data)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ahoy/stores/log_store.rb', line 17

def track_event(name, properties, options, &block)
  data = {
    id: options[:id],
    name: name,
    properties: properties,
    visit_id: ahoy.visit_id,
    visitor_id: ahoy.visitor_id
  }
  data[:user_id] = user.id if user
  data[:time] = options[:time]

  yield(data) if block_given?

  log_event(data)
end

#track_visit(options) {|data| ... } ⇒ Object

Yields:

  • (data)


4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ahoy/stores/log_store.rb', line 4

def track_visit(options, &block)
  data = {
    id: ahoy.visit_id,
    visitor_id: ahoy.visitor_id
  }.merge(visit_properties.to_hash)
  data[:user_id] = user.id if user
  data[:started_at] = options[:started_at]

  yield(data) if block_given?

  log_visit(data)
end