Module: IscAnalytics::KISSMetricsClientAPI
- Included in:
- Bootstrap
- Defined in:
- lib/isc_analytics/client_api.rb
Instance Method Summary collapse
- #clear_identify ⇒ Object
-
#generate_queue_js(reset_queue = true) ⇒ Object
reset_queue makes sure that subsequent calls will not send events that have already been sent.
- #identify(identifier, properties = {}) ⇒ Object
- #keep_km_url_event(params) ⇒ Object
- #set_properties(properties = {}) ⇒ Object
- #set_property(property, value = nil) ⇒ Object
- #track_event(name, properties = {}) ⇒ Object
Instance Method Details
#clear_identify ⇒ Object
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, escape_properties(properties) end set_identity(identifier) end end |
#keep_km_url_event(params) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/isc_analytics/client_api.rb', line 46 def keep_km_url_event(params) kme = params["kme"] if kme props = {} params.each do |key, value| if key.to_s.start_with?("km_") prop_name = key[3..-1] props[prop_name] = value end end track_event(kme, props) end end |
#set_properties(properties = {}) ⇒ Object
31 32 33 |
# File 'lib/isc_analytics/client_api.rb', line 31 def set_properties(properties = {}) enqueue('setProperties', escape_properties(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', CGI::escapeHTML(property), value ? CGI::escapeHTML(value) : 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', CGI::escapeHTML(name) else enqueue 'trackEvent', CGI::escapeHTML(name), escape_properties(properties) end end end |