Class: Mengpaneel::Tracker

Inherits:
Mixpanel::Tracker
  • Object
show all
Defined in:
lib/mengpaneel/tracker.rb

Defined Under Namespace

Classes: People

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, remote_ip = nil) ⇒ Tracker

Returns a new instance of Tracker.


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mengpaneel/tracker.rb', line 10

def initialize(token, remote_ip = nil)
  super(token)
  @people = People.new(self)

  @remote_ip = remote_ip

  @disable_all_events = false
  @disabled_events = []

  @properties = HashWithIndifferentAccess.new
  @properties["ip"] = @remote_ip if @remote_ip
end

Instance Attribute Details

#distinct_idObject (readonly)

Returns the value of attribute distinct_id


8
9
10
# File 'lib/mengpaneel/tracker.rb', line 8

def distinct_id
  @distinct_id
end

#remote_ipObject (readonly)

Returns the value of attribute remote_ip


7
8
9
# File 'lib/mengpaneel/tracker.rb', line 7

def remote_ip
  @remote_ip
end

#tokenObject (readonly)

Returns the value of attribute token


6
7
8
# File 'lib/mengpaneel/tracker.rb', line 6

def token
  @token
end

Instance Method Details

#disable(events = nil) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/mengpaneel/tracker.rb', line 28

def disable(events = nil)
  if events
    @disabled_events += events
  else
    @disable_all_events = true
  end
end

#get_property(property) ⇒ Object


54
55
56
# File 'lib/mengpaneel/tracker.rb', line 54

def get_property(property)
  @properties[property]
end

#identify(distinct_id) ⇒ Object


36
37
38
# File 'lib/mengpaneel/tracker.rb', line 36

def identify(distinct_id)
  @distinct_id = distinct_id
end

#push(item) ⇒ Object


23
24
25
26
# File 'lib/mengpaneel/tracker.rb', line 23

def push(item)
  method_name, args = item
  send(method_name, *args)
end

#register(properties) ⇒ Object


40
41
42
# File 'lib/mengpaneel/tracker.rb', line 40

def register(properties)
  @properties.merge!(properties)
end

#register_once(properties, default_value = "None") ⇒ Object


44
45
46
47
48
# File 'lib/mengpaneel/tracker.rb', line 44

def register_once(properties, default_value = "None")
  @properties.merge!(properties) do |key, oldval, newval|
    oldval.nil? || oldval == default_value ? newval : oldval
  end
end

#track(event, properties = {}) ⇒ Object


58
59
60
61
62
63
64
# File 'lib/mengpaneel/tracker.rb', line 58

def track(event, properties = {})
  return if @disable_all_events || @disabled_events.include?(event)

  properties = @properties.merge(properties)

  super(@distinct_id, event, properties)
end

#unregister(property) ⇒ Object


50
51
52
# File 'lib/mengpaneel/tracker.rb', line 50

def unregister(property)
  @properties.delete(property)
end