KEMBAR78
MixpanelAPI (mixpanel-java 1.5.0 API)
com.mixpanel.mixpanelapi

Class 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.
    • Field Detail

      • mEventsEndpoint

        protected final String mEventsEndpoint
      • mPeopleEndpoint

        protected final String mPeopleEndpoint
      • mGroupsEndpoint

        protected final String mGroupsEndpoint
    • 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 events and people updates. 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()
      • MixpanelAPI

        public MixpanelAPI(String eventsEndpoint,
                           String peopleEndpoint,
                           String groupsEndpoint)
        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
        groupsEndpoint - a URL that will accept Mixpanel groups 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
      • encodeDataString

        protected String encodeDataString(String dataString)
        apply Base64 encoding followed by URL encoding
        Parameters:
        dataString - JSON formatted string
        Returns:
        encoded string for data parameter in API call
        Throws:
        NullPointerException - If dataString is null

Copyright © 2019. All rights reserved.