Package io.fi0x.javalogger.mixpanel
Class MixpanelHandler
java.lang.Object
io.fi0x.javalogger.mixpanel.MixpanelHandler
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddDefaultProperty(String propertyName, String propertyValue) Properties that are added with this method will be appended to all future messages that are sent to Mixpanel.static booleanaddMessage(String eventName, Map<String, String> properties) Add a new message to the Mixpanel delivery queue.static booleanSend all collected messages to Mixpanel immediately.static booleansetMilliDelay(long minMillisBetweenMessages) Set the minimum millisecond delay between each mixpanel delivery.static voidsetProjectToken(String mixpanelProjectToken) Set the project-token that can be obtained from Mixpanel.static voidsetUniqueUserID(String distinctMixpanelID) Set a distinct ID for all Mixpanel messages sent from this application-instance.
-
Method Details
-
sendMessages
public static boolean sendMessages()Send all collected messages to Mixpanel immediately. This will skip the delay between mixpanel messages.- Returns:
- True if delivery was successful, False if there is no delivery or another problem occured.
-
addMessage
Add a new message to the Mixpanel delivery queue. Adding a message requires the uniqueID and projectToken to be set.- Parameters:
eventName- The name of the event. This will also be visible on Mixpanel. This must not be null.properties- The properties for this message. These will be visible and filterable on Mixpanel.- Returns:
- True if the message was successfully added to the queue, False if some information was missing.
-
addDefaultProperty
Properties that are added with this method will be appended to all future messages that are sent to Mixpanel. This is useful for version information and other things that do not change on runtime.- Parameters:
propertyName- The name of the property that will be visible on Mixpanel.propertyValue- The value of the property.- Returns:
- True if the property was added, False if a property with this name already exists.
-
setMilliDelay
public static boolean setMilliDelay(long minMillisBetweenMessages) Set the minimum millisecond delay between each mixpanel delivery.- Parameters:
minMillisBetweenMessages- The time in millis between each mixpanel delivery that should be sent (Min 500, Default is 5000).- Returns:
- True if the new delay was set, False if the delay was too short.
-
setProjectToken
Set the project-token that can be obtained from Mixpanel. This is required to successfully send messages to Mixpanel.- Parameters:
mixpanelProjectToken- The token of you Mixpanel project.
-
setUniqueUserID
Set a distinct ID for all Mixpanel messages sent from this application-instance. You can use a username or UUID to identify users and track them on Mixpanel.- Parameters:
distinctMixpanelID- The distinctID that is added to each Mixpanel message.
-