public class MessageBuilder extends Object
| Constructor and Description |
|---|
MessageBuilder(String token) |
| Modifier and Type | Method and Description |
|---|---|
org.json.JSONObject |
append(String distinctId,
org.json.JSONObject properties)
For each key and value in the properties argument, attempts to append
that value to a list associated with the key in the identified People Analytics profile.
|
org.json.JSONObject |
append(String distinctId,
org.json.JSONObject properties,
org.json.JSONObject modifiers)
For each key and value in the properties argument, attempts to append
that value to a list associated with the key in the identified People Analytics profile.
|
org.json.JSONObject |
delete(String distinctId)
Deletes the People Analytics profile associated with
the given distinctId.
|
org.json.JSONObject |
delete(String distinctId,
org.json.JSONObject modifiers)
Deletes the People Analytics profile associated with
the given distinctId.
|
org.json.JSONObject |
event(String distinctId,
String eventName,
org.json.JSONObject properties)
Creates a message tracking an event, for consumption by MixpanelAPI
See:
http://blog.mixpanel.com/2012/09/12/best-practices-updated/
for a detailed discussion of event names, distinct ids, event properties, and how to use them
to get the most out of your metrics.
|
org.json.JSONObject |
increment(String distinctId,
Map<String,Long> properties)
For each key and value in the properties argument, adds that amount
to the associated property in the People Analytics profile with the given distinct id.
|
org.json.JSONObject |
increment(String distinctId,
Map<String,Long> properties,
org.json.JSONObject modifiers)
For each key and value in the properties argument, adds that amount
to the associated property in the People Analytics profile with the given distinct id.
|
org.json.JSONObject |
peopleMessage(String distinctId,
String actionType,
Object properties,
org.json.JSONObject modifiers)
Formats a generic people message.
|
org.json.JSONObject |
set(String distinctId,
org.json.JSONObject properties)
Sets a People Analytics property on the profile associated with
the given distinctId.
|
org.json.JSONObject |
set(String distinctId,
org.json.JSONObject properties,
org.json.JSONObject modifiers)
Sets a People Analytics property on the profile associated with
the given distinctId.
|
org.json.JSONObject |
setOnce(String distinctId,
org.json.JSONObject properties,
org.json.JSONObject modifiers)
Sets a People Analytics property on the profile associated with
the given distinctId, only if that property is not already set
on the associated profile.
|
org.json.JSONObject |
trackCharge(String distinctId,
double amount,
org.json.JSONObject properties)
Tracks revenue associated with the given distinctId.
|
org.json.JSONObject |
trackCharge(String distinctId,
double amount,
org.json.JSONObject properties,
org.json.JSONObject modifiers)
Tracks revenue associated with the given distinctId.
|
org.json.JSONObject |
union(String distinctId,
Map<String,org.json.JSONArray> properties,
org.json.JSONObject modifiers)
Merges list-valued properties into a user profile.
|
org.json.JSONObject |
unset(String distinctId,
Collection<String> propertyNames,
org.json.JSONObject modifiers)
Removes the properties named in propertyNames from the profile identified by distinctId.
|
public MessageBuilder(String token)
public org.json.JSONObject event(String distinctId, String eventName, org.json.JSONObject properties)
distinctId - a string uniquely identifying the individual cause associated with this event
(for example, the user id of a signing-in user, or the hostname of a server)eventName - a human readable name for the event, for example "Purchase", or "Threw Exception"properties - a JSONObject associating properties with the event. These are useful
for reporting and segmentation of events. It is often useful not only to include
properties of the event itself (for example { 'Item Purchased' : 'Hat' } or
{ 'ExceptionType' : 'OutOfMemory' }), but also properties associated with the
identified user (for example { 'MemberSince' : '2012-01-10' } or { 'TotalMemory' : '10TB' })public org.json.JSONObject set(String distinctId, org.json.JSONObject properties)
JSONObject userProperties = new JSONObject();
userProperties.put("Company", "Uneeda Medical Supply");
userProperties.put("Easter Eggs", "Hatched");
JSONObject message = messageBuilder.set("12345", userProperties);
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to change,
for example, a user id of an app, or the hostname of a server. If no profile
exists for the given id, a new one will be created.properties - a collection of properties to set on the associated profile. Each key
in the properties argument will be updated on on the people profile.public org.json.JSONObject set(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
JSONObject userProperties = new JSONObject();
userProperties.put("Company", "Uneeda Medical Supply");
userProperties.put("Easter Eggs", "Hatched");
JSONObject message = messageBuilder.set("12345", userProperties);
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to change,
for example, a user id of an app, or the hostname of a server. If no profile
exists for the given id, a new one will be created.properties - a collection of properties to set on the associated profile. Each key
in the properties argument will be updated on on the people profilemodifiers - Modifiers associated with the update message. (for example "$time" or "$ignore_time").
this can be null- if non-null, the keys and values in the modifiers
object will be associated directly with the update.public org.json.JSONObject setOnce(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
JSONObject userProperties = new JSONObject();
userProperties.put("Date Began", "2014-08-16");
// "Date Began" will not be overwritten, but if it isn't already
// present it will be set when we send this message.
JSONObject message = messageBuilder.setOnce("12345", userProperties);
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to change,
for example, a user id of an app, or the hostname of a server. If no profile
exists for the given id, a new one will be created.properties - a collection of properties to set on the associated profile. Each key
in the properties argument will be updated on on the people profilemodifiers - Modifiers associated with the update message. (for example "$time" or "$ignore_time").
this can be null- if non-null, the keys and values in the modifiers
object will be associated directly with the update.public org.json.JSONObject delete(String distinctId)
JSONObject message = messageBuilder.delete("12345");
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to deletepublic org.json.JSONObject delete(String distinctId, org.json.JSONObject modifiers)
JSONObject message = messageBuilder.delete("12345");
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to deletemodifiers - Modifiers associated with the update message. (for example "$time" or "$ignore_time").
this can be null- if non-null, the keys and values in the modifiers
object will be associated directly with the update.public org.json.JSONObject increment(String distinctId, Map<String,Long> properties)
Map<String, Long> updates = new HashMap<String, Long>();
updates.put('Logins', 1);
JSONObject message = messageBuilder.set("12345", updates);
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to change,
for example, a user id of an app, or the hostname of a server. If no profile
exists for the given id, a new one will be created.properties - a collection of properties to change on the associated profile,
each associated with a numeric value.public org.json.JSONObject increment(String distinctId, Map<String,Long> properties, org.json.JSONObject modifiers)
Map<String, Long> updates = new HashMap<String, Long>();
updates.put('Logins', 1);
JSONObject message = messageBuilder.set("12345", updates);
mixpanelApi.sendMessage(message);
distinctId - a string uniquely identifying the people analytics profile to change,
for example, a user id of an app, or the hostname of a server. If no profile
exists for the given id, a new one will be created.properties - a collection of properties to change on the associated profile,
each associated with a numeric value.modifiers - Modifiers associated with the update message. (for example "$time" or "$ignore_time").
this can be null- if non-null, the keys and values in the modifiers
object will be associated directly with the update.public org.json.JSONObject append(String distinctId, org.json.JSONObject properties)
public org.json.JSONObject append(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
public org.json.JSONObject union(String distinctId, Map<String,org.json.JSONArray> properties, org.json.JSONObject modifiers)
public org.json.JSONObject unset(String distinctId, Collection<String> propertyNames, org.json.JSONObject modifiers)
public org.json.JSONObject trackCharge(String distinctId, double amount, org.json.JSONObject properties)
distinctId - an identifier associated with a People Analytics profileamount - a double revenue amount. Positive amounts represent income for your business.properties - can be null. If provided, a set of properties to associate with
the individual transaction.public org.json.JSONObject trackCharge(String distinctId, double amount, org.json.JSONObject properties, org.json.JSONObject modifiers)
distinctId - an identifier associated with a People Analytics profileamount - a double revenue amount. Positive amounts represent income for your business.properties - can be null. If provided, a set of properties to associate with
the individual transaction.modifiers - can be null. If provided, the keys and values in the object will
be merged as modifiers associated with the update message (for example, "$time" or "$ignore_time")public org.json.JSONObject peopleMessage(String distinctId, String actionType, Object properties, org.json.JSONObject modifiers)
distinctId - a string uniquely identifying the individual cause associated with this event
(for example, the user id of a signing-in user, or the hostname of a server)actionType - a string associated in the HTTP api with the operation (for example, $set or $add)properties - a payload of the operation. Will be converted to JSON, and should be of types
Boolean, Double, Integer, Long, String, JSONArray, JSONObject, the JSONObject.NULL object, or null.
NaN and negative/positive infinity will throw an IllegalArgumentExceptionmodifiers - if provided, the keys and values in the modifiers object will
be merged as modifiers associated with the update message (for example, "$time" or "$ignore_time")IllegalArgumentException - if properties is not intelligible as a JSONObject propertyset(String distinctId, JSONObject properties),
delete(String distinctId),
MessageBuilder#increment(String distinctId, Map properties) ,
append(String distinctId, JSONObject properties, JSONObject modifiers)Copyright © 2016. All rights reserved.