Created
August 25, 2011 13:58
-
-
Save gsiener/1170721 to your computer and use it in GitHub Desktop.
A much simpler approach to using Kissmetrics instead of the provided gem. Requires delayed_job and httparty gems.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KM | |
@id = nil | |
@key = nil | |
class << self | |
def init(key) | |
@key = key | |
end | |
def identify(id) | |
@id = id | |
end | |
def record(e) | |
p = { | |
'_n' => e, | |
'_p' => @id, | |
'_t' => Time.now.to_i.to_s, | |
'_k' => @key, | |
} | |
HTTParty.delay.get('http://trk.kissmetrics.com/e?' + p.to_params) | |
end | |
def alias(name, alias_to) | |
p = { | |
'_n' => alias_to, | |
'_p' => name, | |
'_t' => Time.now.to_i.to_s, | |
'_k' => @key, | |
} | |
HTTParty.delay.get('http://trk.kissmetrics.com/a?' + p.to_params) | |
end | |
def set(p) | |
p['_p'] = name | |
p['_t'] = Time.now.to_i.to_s | |
p['_k'] = @key | |
HTTParty.delay.get('http://trk.kissmetrics.com/s?' + p.to_params) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment