com.mixpanel.mixpanelapi
Class MixpanelAPI

java.lang.Object
  extended by com.mixpanel.mixpanelapi.MixpanelAPI

public class MixpanelAPI
extends Object

Simple interface to the Mixpanel tracking API, intended for use in server-side applications. Users are encouraged to review our Javascript API for reporting user events in web applications, and our Android API for use in Android mobile applications. The Java API doesn't provide or assume any threading model, and is designed such that recording events and sending them can be easily separated.


Constructor Summary
MixpanelAPI()
          Constructs a MixpanelAPI object associated with the production, Mixpanel services.
MixpanelAPI(String eventsEndpoint, String peopleEndpoint)
          Create a MixpaneAPI associated with custom URLS for the Mixpanel service.
 
Method Summary
 void deliver(ClientDelivery toSend)
          Sends a ClientDelivery full of messages to Mixpanel's servers.
 void deliver(ClientDelivery toSend, boolean useIpAddress)
          Attempts to send a given delivery to the Mixpanel servers.
 void sendMessage(org.json.JSONObject message)
          Sends a single message to Mixpanel servers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MixpanelAPI

public MixpanelAPI()
Constructs a MixpanelAPI object associated with the production, Mixpanel services.


MixpanelAPI

public MixpanelAPI(String eventsEndpoint,
                   String peopleEndpoint)
Create a MixpaneAPI associated with custom URLS for the Mixpanel service. Useful for testing and proxying. Most callers should use the constructor with no arguments.

Parameters:
eventsEndpoint - a URL that will accept Mixpanel events messages
peopleEndpoint - a URL that will accept Mixpanel people messages
See Also:
MixpanelAPI()
Method Detail

sendMessage

public void sendMessage(org.json.JSONObject message)
                 throws MixpanelMessageException,
                        IOException
Sends a single message to Mixpanel servers. Each call to sendMessage results in a blocking call to remote Mixpanel servers. To send multiple messages at once, see #deliver(ClientDelivery)

Parameters:
message - A JSONObject formatted by #MessageBuilder
Throws:
MixpanelMessageException - if the given JSONObject is not (apparently) a Mixpanel message. This is a RuntimeException, callers should take care to submit only correctly formatted messages.
IOException - if

deliver

public void deliver(ClientDelivery toSend)
             throws IOException
Sends a ClientDelivery full of messages to Mixpanel's servers. This call will block, possibly for a long time.

Parameters:
toSend -
Throws:
IOException
See Also:
ClientDelivery

deliver

public void deliver(ClientDelivery toSend,
                    boolean useIpAddress)
             throws IOException
Attempts to send a given delivery to the Mixpanel servers. Will block, possibly on multiple server requests. For most applications, this method should be called in a separate thread or in a queue consumer.

Parameters:
toSend - a ClientDelivery containing a number of Mixpanel messages
Throws:
IOException
See Also:
ClientDelivery


Copyright © 2014. All Rights Reserved.