Module: IscAnalytics::KISSMetricsClientAPI

Included in:
Bootstrap
Defined in:
lib/isc_analytics/client_api.rb

Instance Method Summary collapse

Instance Method Details

#clear_identifyObject



16
17
18
19
# File 'lib/isc_analytics/client_api.rb', line 16

def clear_identify
  set_identity(nil) # removed identity from session
  enqueue 'clearIdentity'
end

#generate_queue_js(reset_queue = true) ⇒ Object

reset_queue makes sure that subsequent calls will not send events that have already been sent.



40
41
42
43
44
# File 'lib/isc_analytics/client_api.rb', line 40

def generate_queue_js(reset_queue = true)
  buffer = get_parsed_queue_string
  queue.clear if reset_queue
  buffer
end

#identify(identifier, properties = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/isc_analytics/client_api.rb', line 4

def identify(identifier, properties = {})
  unless identifier.blank? || is_identified(identifier)
    remove_duplicated_identify
    if properties.blank?
      enqueue 'identify', identifier
    else
      enqueue 'identify', identifier, properties
    end
    set_identity(identifier)
  end
end

#set_properties(properties = {}) ⇒ Object



31
32
33
# File 'lib/isc_analytics/client_api.rb', line 31

def set_properties(properties = {})
  enqueue('setProperties', properties) unless properties.blank?
end

#set_property(property, value = nil) ⇒ Object



35
36
37
# File 'lib/isc_analytics/client_api.rb', line 35

def set_property(property, value = nil)
  enqueue('setProperty', property, value) unless property.blank?
end

#track_event(name, properties = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/isc_analytics/client_api.rb', line 21

def track_event(name, properties = {})
  unless name.blank?
    if properties.blank?
      enqueue 'trackEvent', name
    else
      enqueue 'trackEvent', name, properties
    end
  end
end