Created
February 8, 2013 23:59
-
-
Save interhive/4742996 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'base64' | |
require 'json' | |
require 'httparty' | |
# based on https://mixpanel.com/docs/integration-libraries/ruby. Changed to use httpparty, rather than fork a process | |
module MixPanel | |
include HTTParty | |
TOKEN = "PUT YOUR TOKEN HERE" | |
base_uri "https://api.mixpanel.com/" | |
def self.track(event, properties={}) | |
properties[:token] = TOKEN | |
params = {event: event, properties: properties} | |
data = Base64.strict_encode64(JSON.generate(params)) | |
post URI.encode "/track?data=#{data}" | |
end | |
end | |
data = { | |
key: "value", | |
user_agent: "chrome", | |
content_type: "json" | |
} | |
MixPanel.track("now on the body", data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment