public class MessageBuilder extends Object
| Constructor and Description |
|---|
MessageBuilder(String writeKey) |
| Modifier and Type | Method and Description |
|---|---|
org.json.JSONObject |
event(String distinctId,
String eventName,
String eventType,
org.json.JSONObject properties) |
org.json.JSONObject |
getDefaultPayload(String eventType) |
String |
guid() |
org.json.JSONObject |
identify(String distinctId,
String eventType,
Object traits)
Formats a generic identify message.
|
String |
returnISODate() |
org.json.JSONObject |
set(String distinctId,
String eventType,
org.json.JSONObject traits)
Sets User property on the profile associated with the given distinctId or userID.
|
public MessageBuilder(String writeKey)
public String guid()
public String returnISODate()
public org.json.JSONObject getDefaultPayload(String eventType)
public org.json.JSONObject event(String distinctId, String eventName, String eventType, org.json.JSONObject properties)
distinctId - a string uniquely identifying the individual with whom this event is related.
(for example, the user id of a signing-in user, or the hostname of a server)
For userId it is always better to give database id for unique identificationeventType - should be "track" for the track callseventName - a human readable name for the event, for example "Add to Cart", or "Viewed Dashboard Page"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' : 'Dress' } or {'variantId':'1234'}public org.json.JSONObject set(String distinctId, String eventType, org.json.JSONObject traits)
JSONObject traits = new JSONObject();
traits.put("Company", "Uneeda Medical Supply");
trauts.put("Easter Eggs", "Hatched");
JSONObject message = messageBuilder.set("ABCD", traits);
connectoApi.sendMessage(message);
distinctId - a string uniquely identifying the user.
The optimal solution is to choose your Database Id as unique identifier as that
will remain constant throughout even if the user will change email id etc.
If no profile exists for the given id, a new one will be created.traits - a collection of traits to set on the associated profile. Each key
in the traits argument will be updated on on the user profiles.public org.json.JSONObject identify(String distinctId, String eventType, Object traits)
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)eventType - should be "identify" for the identify callstraits - 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 IllegalArgumentExceptionIllegalArgumentException - if traits is not intelligible as a JSONObject propertyset(String distinctId, String eventType, JSONObject traits)Copyright © 2015. All rights reserved.