Class: Ahoy::Stores::ActiveRecordStore
Instance Method Summary
collapse
Methods inherited from BaseStore
#authenticate, #exclude?, #generate_id, #initialize, #report_exception, #user
Instance Method Details
#track_event(name, properties, options) {|event| ... } ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ahoy/stores/active_record_store.rb', line 26
def track_event(name, properties, options, &block)
event =
event_model.new do |e|
e.id = options[:id]
e.visit_id = ahoy.visit_id
e.user = user if e.respond_to?(:user=)
e.name = name
e.properties = properties
e.time = options[:time]
end
yield(event) if block_given?
begin
event.save!
rescue *unique_exception_classes
end
end
|
#track_visit(options) {|visit| ... } ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ahoy/stores/active_record_store.rb', line 4
def track_visit(options, &block)
@visit =
visit_model.new do |v|
v.id = ahoy.visit_id
v.visitor_id = ahoy.visitor_id
v.user = user if v.respond_to?(:user=)
v.started_at = options[:started_at]
end
set_visit_properties(visit)
yield(visit) if block_given?
begin
visit.save!
geocode(visit)
rescue *unique_exception_classes
@visit = nil
end
end
|
#visit ⇒ Object
46
47
48
|
# File 'lib/ahoy/stores/active_record_store.rb', line 46
def visit
@visit ||= visit_model.where(id: ahoy.visit_id).first if ahoy.visit_id
end
|