Module: Kontagent
- Defined in:
- lib/kontagent.rb
Constant Summary collapse
- PARAMS_MAP =
{ :uid => :s, :birth_year => :b, :sex => [:g, :escape], :city => [:ly, :escape], :country => [:lc, :escape], :zip => [:lp, :escape], :state => [:ls, :escape], :friend_count => :f, :short_tag => :su, :tag => :u, :channel => :tu, :link_type => :tu, :st1 => [:st1, :escape], :st2 => [:st2, :escape], :st3 => [:st3, :escape], :responder_uid => :r, :recipient_uids => [:r, :escape], :existing_install? => :i, :timestamp => :ts, }
Class Method Summary collapse
- .application_added(options = {}) ⇒ Object
- .application_removed(options = {}) ⇒ Object
- .base_url ⇒ Object
- .build_url(method, options = {}) ⇒ Object
- .config ⇒ Object
- .create_short_tag ⇒ Object
- .create_tracking_tag {|tag| ... } ⇒ Object
- .get_page_request_url(options = {}) ⇒ Object
- .initialize!(options = {}) ⇒ Object
- .track_invite(options = {}) ⇒ Object
- .track_invite_response(options = {}) ⇒ Object
- .track_link(options) ⇒ Object
- .track_post(options = {}) ⇒ Object
- .track_post_response(options = {}) ⇒ Object
- .track_user(options = {}) ⇒ Object
Class Method Details
.application_added(options = {}) ⇒ Object
54 55 56 57 |
# File 'lib/kontagent.rb', line 54 def self.application_added( = {}) (, :uid) call_method("apa", ) end |
.application_removed(options = {}) ⇒ Object
59 60 61 62 |
# File 'lib/kontagent.rb', line 59 def self.application_removed( = {}) (, :uid) call_method("apr", ) end |
.base_url ⇒ Object
11 12 13 |
# File 'lib/kontagent.rb', line 11 def self.base_url @@base_url end |
.build_url(method, options = {}) ⇒ Object
101 102 103 |
# File 'lib/kontagent.rb', line 101 def self.build_url(method, = {}) File.join(self.base_url, method, "?#{kontagent_params()}") end |
.config ⇒ Object
7 8 9 |
# File 'lib/kontagent.rb', line 7 def self.config @@config end |
.create_short_tag ⇒ Object
43 44 45 |
# File 'lib/kontagent.rb', line 43 def self.create_short_tag create_tracking_tag end |
.create_tracking_tag {|tag| ... } ⇒ Object
37 38 39 40 41 |
# File 'lib/kontagent.rb', line 37 def self.create_tracking_tag tag = UUID.random_create.to_s.gsub("-", "") yield tag if block_given? tag end |
.get_page_request_url(options = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/kontagent.rb', line 64 def self.get_page_request_url( = {}) (, :uid) [:timestamp] ||= Time.now.strftime("%Y-%m-%dT%H:%M:%S") build_url("pgr", ) end |
.initialize!(options = {}) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/kontagent.rb', line 47 def self.initialize!( = {}) raise "Missing required api_url setting" unless ["api_url"] raise "Missing required ab_url setting" unless ["ab_url"] @@config = OpenStruct.new() @@base_url = File.join(self.config.api_url, self.config.api_key) end |
.track_invite(options = {}) ⇒ Object
89 90 91 92 93 |
# File 'lib/kontagent.rb', line 89 def self.track_invite( = {}) (, :uid, :tag, :recipient_uids) [:recipient_uids] = [:recipient_uids].join(",") call_method("ins", ) end |
.track_invite_response(options = {}) ⇒ Object
95 96 97 98 99 |
# File 'lib/kontagent.rb', line 95 def self.track_invite_response( = {}) (, :responder_uid, :tag, :existing_install?) [:existing_install?] = [:existing_install?] && 1 || 0 call_method("inr", ) end |
.track_link(options) ⇒ Object
105 106 107 108 109 |
# File 'lib/kontagent.rb', line 105 def self.track_link() (, :link_type, :existing_install?, :short_tag) [:existing_install?] = [:existing_install?] ? 1 : 0 call_method("ucc", ) end |
.track_post(options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/kontagent.rb', line 76 def self.track_post( = {}) (, :uid, :tag, :channel) assert_channel([:channel]) call_method("pst", ) end |
.track_post_response(options = {}) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/kontagent.rb', line 82 def self.track_post_response( = {}) (, :responder_uid, :tag, :channel, :existing_install?) assert_channel([:channel]) [:existing_install?] = [:existing_install?] && 1 || 0 call_method("psr", ) end |
.track_user(options = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/kontagent.rb', line 70 def self.track_user( = {}) (, :uid) [:sex] = [:sex].to_s[0,1] call_method("cpu", ) end |