Package com.mixpanel.mixpanelapi
Class MessageBuilder
- java.lang.Object
-
- com.mixpanel.mixpanelapi.MessageBuilder
-
public class MessageBuilder extends Object
This class writes JSONObjects of a form appropriate to send as Mixpanel events and updates to profiles via the MixpanelAPI class. Instances of this class can be instantiated separately from instances of MixpanelAPI, and the resulting messages are suitable for enqueuing or sending over a local network.
-
-
Constructor Summary
Constructors Constructor Description MessageBuilder(String token)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.json.JSONObjectappend(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 profile.org.json.JSONObjectappend(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 profile.org.json.JSONObjectdelete(String distinctId)Deletes the profile associated with the given distinctId.org.json.JSONObjectdelete(String distinctId, org.json.JSONObject modifiers)Deletes the profile associated with the given distinctId.org.json.JSONObjectevent(String distinctId, String eventName, org.json.JSONObject properties)Creates a message tracking an event, for consumption by MixpanelAPI See: https://help.mixpanel.com/hc/en-us/articles/360000857366-Guide-to-Mixpanel-Basics 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.JSONObjectgroupDelete(String groupKey, String groupId)Deletes the group profile identified by the given groupKey and groupId.org.json.JSONObjectgroupDelete(String groupKey, String groupId, org.json.JSONObject modifiers)Deletes the group profile identified by the given groupKey and groupId.org.json.JSONObjectgroupMessage(String groupKey, String groupId, String actionType, Object properties, org.json.JSONObject modifiers)Formats a generic group profile message.org.json.JSONObjectgroupRemove(String groupKey, String groupId, org.json.JSONObject properties)For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified group profile.org.json.JSONObjectgroupRemove(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified group profile.org.json.JSONObjectgroupSet(String groupKey, String groupId, org.json.JSONObject properties)Sets properties on the group profile identified by the given groupKey and groupId, creating the profile if needed.org.json.JSONObjectgroupSet(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)Sets properties on the group profile identified by the given groupKey and groupId, creating the profile if needed.org.json.JSONObjectgroupSetOnce(String groupKey, String groupId, org.json.JSONObject properties)Sets properties if they do not already exist on the group profile identified by the given groupKey and groupId.org.json.JSONObjectgroupSetOnce(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)Sets properties if they do not already exist on the group profile identified by the given groupKey and groupId.org.json.JSONObjectgroupUnion(String groupKey, String groupId, Map<String,org.json.JSONArray> properties)Merges list-valued properties into a group profile.org.json.JSONObjectgroupUnion(String groupKey, String groupId, Map<String,org.json.JSONArray> properties, org.json.JSONObject modifiers)Merges list-valued properties into a group profile.org.json.JSONObjectgroupUnset(String groupKey, String groupId, Collection<String> propertyNames)Removes the properties named in propertyNames from the group profile identified by groupKey and groupId.org.json.JSONObjectgroupUnset(String groupKey, String groupId, Collection<String> propertyNames, org.json.JSONObject modifiers)Removes the properties named in propertyNames from the group profile identified by groupKey and groupId.org.json.JSONObjectincrement(String distinctId, Map<String,Long> properties)For each key and value in the properties argument, adds that amount to the associated property in the profile with the given distinct id.org.json.JSONObjectincrement(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 profile with the given distinct id.org.json.JSONObjectpeopleMessage(String distinctId, String actionType, Object properties, org.json.JSONObject modifiers)Formats a generic user profile message.org.json.JSONObjectremove(String distinctId, org.json.JSONObject properties)For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified user profile.org.json.JSONObjectremove(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified user profile.org.json.JSONObjectset(String distinctId, org.json.JSONObject properties)Sets a property on the profile associated with the given distinctId.org.json.JSONObjectset(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)Sets a property on the profile associated with the given distinctId.org.json.JSONObjectsetOnce(String distinctId, org.json.JSONObject properties)Sets a property on the profile associated with the given distinctId, only if that property is not already set on the associated profile.org.json.JSONObjectsetOnce(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)Sets a property on the profile associated with the given distinctId, only if that property is not already set on the associated profile.org.json.JSONObjecttrackCharge(String distinctId, double amount, org.json.JSONObject properties)Tracks revenue associated with the given distinctId.org.json.JSONObjecttrackCharge(String distinctId, double amount, org.json.JSONObject properties, org.json.JSONObject modifiers)Tracks revenue associated with the given distinctId.org.json.JSONObjectunion(String distinctId, Map<String,org.json.JSONArray> properties)Merges list-valued properties into a user profile.org.json.JSONObjectunion(String distinctId, Map<String,org.json.JSONArray> properties, org.json.JSONObject modifiers)Merges list-valued properties into a user profile.org.json.JSONObjectunset(String distinctId, Collection<String> propertyNames)Removes the properties named in propertyNames from the profile identified by distinctId.org.json.JSONObjectunset(String distinctId, Collection<String> propertyNames, org.json.JSONObject modifiers)Removes the properties named in propertyNames from the profile identified by distinctId.
-
-
-
Constructor Detail
-
MessageBuilder
public MessageBuilder(String token)
-
-
Method Detail
-
event
public org.json.JSONObject event(String distinctId, String eventName, org.json.JSONObject properties)
Creates a message tracking an event, for consumption by MixpanelAPI See: https://help.mixpanel.com/hc/en-us/articles/360000857366-Guide-to-Mixpanel-Basics for a detailed discussion of event names, distinct ids, event properties, and how to use them to get the most out of your metrics.- Parameters:
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' })- Returns:
- event message for consumption by MixpanelAPI
-
set
public org.json.JSONObject set(String distinctId, org.json.JSONObject properties)
Sets a property on the profile associated with the given distinctId. When sent, this message will overwrite any existing values for the given properties. So, to set some properties on user 12345, one might call:JSONObject userProperties = new JSONObject(); userProperties.put("Company", "Uneeda Medical Supply"); userProperties.put("Easter Eggs", "Hatched"); JSONObject message = messageBuilder.set("12345", userProperties); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the 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 profile.- Returns:
- user profile set message for consumption by MixpanelAPI
-
set
public org.json.JSONObject set(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
Sets a property on the profile associated with the given distinctId. When sent, this message will overwrite any existing values for the given properties. So, to set some properties on user 12345, one might call:JSONObject userProperties = new JSONObject(); userProperties.put("Company", "Uneeda Medical Supply"); userProperties.put("Easter Eggs", "Hatched"); JSONObject message = messageBuilder.set("12345", userProperties); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the 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 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.- Returns:
- user profile set message for consumption by MixpanelAPI
-
setOnce
public org.json.JSONObject setOnce(String distinctId, org.json.JSONObject properties)
Sets a property on the profile associated with the given distinctId, only if that property is not already set on the associated profile. So, to set a new property on on user 12345 if it is not already present, one might call: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);- Parameters:
distinctId- a string uniquely identifying the 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 profile- Returns:
- user profile setOnce message for consumption by MixpanelAPI
-
setOnce
public org.json.JSONObject setOnce(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
Sets a property on the profile associated with the given distinctId, only if that property is not already set on the associated profile. So, to set a new property on on user 12345 if it is not already present, one might call: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);- Parameters:
distinctId- a string uniquely identifying the 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 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.- Returns:
- user profile setOnce message for consumption by MixpanelAPI
-
delete
public org.json.JSONObject delete(String distinctId)
Deletes the profile associated with the given distinctId.JSONObject message = messageBuilder.delete("12345"); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the profile to delete- Returns:
- user profile delete message for consumption by MixpanelAPI
-
delete
public org.json.JSONObject delete(String distinctId, org.json.JSONObject modifiers)
Deletes the profile associated with the given distinctId.JSONObject message = messageBuilder.delete("12345"); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the 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.- Returns:
- user profile delete message for consumption by MixpanelAPI
-
increment
public 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 profile with the given distinct id. So, to maintain a login count for user 12345, one might run the following code at every login:Map<String, Long> updates = new HashMap<String, Long>(); updates.put('Logins', 1); JSONObject message = messageBuilder.set("12345", updates); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the 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.- Returns:
- user profile increment message for consumption by MixpanelAPI
-
increment
public 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 profile with the given distinct id. So, to maintain a login count for user 12345, one might run the following code at every login:Map<String, Long> updates = new HashMap<String, Long>(); updates.put('Logins', 1); JSONObject message = messageBuilder.set("12345", updates); mixpanelApi.sendMessage(message);- Parameters:
distinctId- a string uniquely identifying the 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.- Returns:
- user profile increment message for consumption by MixpanelAPI
-
append
public 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 profile.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the append operation- Returns:
- user profile append message for consumption by MixpanelAPI
-
append
public 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 profile.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the append operationmodifiers- 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.- Returns:
- user profile append message for consumption by MixpanelAPI
-
remove
public org.json.JSONObject remove(String distinctId, org.json.JSONObject properties)
For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified user profile.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the remove operation- Returns:
- user profile remove message for consumption by MixpanelAPI
-
remove
public org.json.JSONObject remove(String distinctId, org.json.JSONObject properties, org.json.JSONObject modifiers)
For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified user profile.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the remove operationmodifiers- 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.- Returns:
- user profile remove message for consumption by MixpanelAPI
-
union
public org.json.JSONObject union(String distinctId, Map<String,org.json.JSONArray> properties)
Merges list-valued properties into a user profile. The list values in the given are merged with the existing list on the user profile, ignoring duplicate list values.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the union operation- Returns:
- user profile union message for consumption by MixpanelAPI
-
union
public org.json.JSONObject union(String distinctId, Map<String,org.json.JSONArray> properties, org.json.JSONObject modifiers)
Merges list-valued properties into a user profile. The list values in the given are merged with the existing list on the user profile, ignoring duplicate list values.- Parameters:
distinctId- a string uniquely identifying the 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- properties for the union operationmodifiers- 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.- Returns:
- user profile union message for consumption by MixpanelAPI
-
unset
public org.json.JSONObject unset(String distinctId, Collection<String> propertyNames)
Removes the properties named in propertyNames from the profile identified by distinctId.- Parameters:
distinctId- a string uniquely identifying the 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.propertyNames- properties for the unset operation- Returns:
- user profile unset message for consumption by MixpanelAPI
-
unset
public 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.- Parameters:
distinctId- a string uniquely identifying the 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.propertyNames- properties for the unset operationmodifiers- 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.- Returns:
- user profile unset message for consumption by MixpanelAPI
-
trackCharge
public org.json.JSONObject trackCharge(String distinctId, double amount, org.json.JSONObject properties)
Tracks revenue associated with the given distinctId.- Parameters:
distinctId- an identifier associated with a 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.- Returns:
- user profile trackCharge message for consumption by MixpanelAPI
-
trackCharge
public org.json.JSONObject trackCharge(String distinctId, double amount, org.json.JSONObject properties, org.json.JSONObject modifiers)
Tracks revenue associated with the given distinctId.- Parameters:
distinctId- an identifier associated with a 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")- Returns:
- user profile trackCharge message for consumption by MixpanelAPI
-
peopleMessage
public org.json.JSONObject peopleMessage(String distinctId, String actionType, Object properties, org.json.JSONObject modifiers)
Formats a generic user profile message. Use of this method requires familiarity with the underlying Mixpanel HTTP API, and it may be simpler and clearer to use the pre-built functions for setting, incrementing, and appending to properties. Use this method directly only when interacting with experimental APIs, or APIS that the rest of this library does not yet support. The underlying API is documented at https://developer.mixpanel.com/docs/http- Parameters:
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")- Returns:
- generic user profile message for consumption by MixpanelAPI
- Throws:
IllegalArgumentException- if properties is not intelligible as a JSONObject property- See Also:
set(String distinctId, JSONObject properties),delete(String distinctId),append(String distinctId, JSONObject properties, JSONObject modifiers)
-
groupSet
public org.json.JSONObject groupSet(String groupKey, String groupId, org.json.JSONObject properties)
Sets properties on the group profile identified by the given groupKey and groupId, creating the profile if needed. Existing values for the given properties are replaced. Example:JSONObject groupProperties = new JSONObject(); groupProperties.put("$name", "Acme Incorporated"); groupProperties.put("Industry", "Manufacturing"); JSONObject message = messageBuilder.groupSet("company", "Acme Inc.", groupProperties); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- a collection of properties to set on the associated profile. Each key in the properties argument will be updated on on the profile.- Returns:
- group profile set message for consumption by MixpanelAPI
-
groupSet
public org.json.JSONObject groupSet(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)
Sets properties on the group profile identified by the given groupKey and groupId, creating the profile if needed. Existing values for the given properties are replaced. Example:JSONObject groupProperties = new JSONObject(); groupProperties.put("$name", "Acme Incorporated"); groupProperties.put("Industry", "Manufacturing"); JSONObject message = messageBuilder.groupSet("company", "Acme Inc.", groupProperties); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- a collection of properties to set on the associated profile. Each key in the properties argument will be updated on on the profile.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.- Returns:
- group profile set message for consumption by MixpanelAPI
-
groupSetOnce
public org.json.JSONObject groupSetOnce(String groupKey, String groupId, org.json.JSONObject properties)
Sets properties if they do not already exist on the group profile identified by the given groupKey and groupId. Example:JSONObject groupProperties = new JSONObject(); groupProperties.put("First Purchase", "Steel"); JSONObject message = messageBuilder.groupSetOnce("company", "Acme Inc.", groupProperties); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- a collection of properties to set on the associated profile. Each key in the properties argument will be updated on on the profile.- Returns:
- group profile setOnce message for consumption by MixpanelAPI
-
groupSetOnce
public org.json.JSONObject groupSetOnce(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)
Sets properties if they do not already exist on the group profile identified by the given groupKey and groupId. Example:JSONObject groupProperties = new JSONObject(); groupProperties.put("First Purchase", "Steel"); JSONObject message = messageBuilder.groupSetOnce("company", "Acme Inc.", groupProperties); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- a collection of properties to set on the associated profile. Each key in the properties argument will be updated on on the profile.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.- Returns:
- group profile setOnce message for consumption by MixpanelAPI
-
groupDelete
public org.json.JSONObject groupDelete(String groupKey, String groupId)
Deletes the group profile identified by the given groupKey and groupId.JSONObject message = messageBuilder.groupDelete("company", "Acme Inc."); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific group- Returns:
- group profile delete message for consumption by MixpanelAPI
-
groupDelete
public org.json.JSONObject groupDelete(String groupKey, String groupId, org.json.JSONObject modifiers)
Deletes the group profile identified by the given groupKey and groupId.JSONObject message = messageBuilder.groupDelete("company", "Acme Inc."); mixpanelApi.sendMessage(message);- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupmodifiers- 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.- Returns:
- group profile delete message for consumption by MixpanelAPI
-
groupRemove
public org.json.JSONObject groupRemove(String groupKey, String groupId, org.json.JSONObject properties)
For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified group profile.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- properties for the remove operation- Returns:
- group profile remove message for consumption by MixpanelAPI
-
groupRemove
public org.json.JSONObject groupRemove(String groupKey, String groupId, org.json.JSONObject properties, org.json.JSONObject modifiers)
For each key and value in the properties argument, attempts to remove that value from a list associated with the key in the specified group profile.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- properties for the remove operationmodifiers- 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.- Returns:
- group profile remove message for consumption by MixpanelAPI
-
groupUnion
public org.json.JSONObject groupUnion(String groupKey, String groupId, Map<String,org.json.JSONArray> properties)
Merges list-valued properties into a group profile. The list values given are merged with the existing list on the group profile, ignoring duplicate list values.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- properties for the union operation- Returns:
- group profile union message for consumption by MixpanelAPI
-
groupUnion
public org.json.JSONObject groupUnion(String groupKey, String groupId, Map<String,org.json.JSONArray> properties, org.json.JSONObject modifiers)
Merges list-valued properties into a group profile. The list values given are merged with the existing list on the group profile, ignoring duplicate list values.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific groupproperties- properties for the union operationmodifiers- 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.- Returns:
- group profile union message for consumption by MixpanelAPI
-
groupUnset
public org.json.JSONObject groupUnset(String groupKey, String groupId, Collection<String> propertyNames)
Removes the properties named in propertyNames from the group profile identified by groupKey and groupId.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific grouppropertyNames- properties for the unset operation- Returns:
- group profile unset message for consumption by MixpanelAPI
-
groupUnset
public org.json.JSONObject groupUnset(String groupKey, String groupId, Collection<String> propertyNames, org.json.JSONObject modifiers)
Removes the properties named in propertyNames from the group profile identified by groupKey and groupId.- Parameters:
groupKey- the property that connects event data for Group AnalyticsgroupId- the identifier for a specific grouppropertyNames- properties for the unset operationmodifiers- 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.- Returns:
- group profile unset message for consumption by MixpanelAPI
-
groupMessage
public org.json.JSONObject groupMessage(String groupKey, String groupId, String actionType, Object properties, org.json.JSONObject modifiers)
Formats a generic group profile message. Use of this method requires familiarity with the underlying Mixpanel HTTP API, and it may be simpler and clearer to use the pre-built update methods. Use this method directly only when interacting with experimental APIs, or APIS that the rest of this library does not yet support. The underlying API is documented at https://mixpanel.com/help/reference/http- Parameters:
groupKey- string identifier for the type of group, e.g. 'Company'groupId- unique string identifier for the group, e.g. 'Acme Inc.'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")- Returns:
- generic group profile message for consumption by MixpanelAPI
- Throws:
IllegalArgumentException- if properties is not intelligible as a JSONObject property- See Also:
groupSet(String groupKey, String groupId, JSONObject properties),groupSetOnce(String groupKey, String groupId, JSONObject properties),groupRemove(String groupKey, String groupId, JSONObject properties),groupDelete(String groupKey, String groupId)
-
-