Created
January 31, 2009 19:08
-
-
Save tdavis/55633 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
import subprocess | |
def mixpanel_log(**kwargs): | |
""" | |
A simple function for asynchronously logging to the mixpanel.com API. | |
This function requires `curl` and Python version 2.4 or higher. | |
@param **kwargs: The parameters for the logging request. For a list of | |
parameters see http://mixpanel.com/api/. | |
@return Instance of L{subprocess.Popen} | |
""" | |
# Make sure we got the required parameters | |
if "project" not in kwargs or "category" not in kwargs: | |
raise ValueError, "You are missing a required parameter. \ | |
See http://mixpanel.com/api/." | |
host = "http://api.mixpanel.com/?" | |
params = "&".join(["%s=%s"%(k,v) for k,v in kwargs.items()]) | |
request = host + params | |
print request | |
return subprocess.Popen(("curl",request), stderr=subprocess.PIPE, | |
stdout=subprocess.PIPE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment