Package com.mixpanel.android.mpmetrics
Interface MixpanelAPI.People
-
- Enclosing class:
- MixpanelAPI
public static interface MixpanelAPI.People
Core interface for using Mixpanel People Analytics features. You can get an instance by callingMixpanelAPI.getPeople()
The People object is used to update properties in a user's People Analytics record. For this reason, it's important to call
identify(String)
on the People object before you work with it. Once you call identify, the user identity will persist across stops and starts of your application, until you make another call to identify using a different id. A typical use case for the People object might look like this:public class MainActivity extends Activity { MixpanelAPI mMixpanel; public void onCreate(Bundle saved) { mMixpanel = MixpanelAPI.getInstance(this, "YOUR MIXPANEL API TOKEN"); mMixpanel.identify("A UNIQUE ID FOR THIS USER"); ... } public void userUpdatedJobTitle(String newTitle) { mMixpanel.getPeople().set("Job Title", newTitle); ... } public void onDestroy() { mMixpanel.flush(); super.onDestroy(); } }
- See Also:
MixpanelAPI
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
append(java.lang.String name, java.lang.Object value)
Appends a value to a list-valued property.void
clearCharges()
Permanently clear the whole transaction history for the identified people profile.void
deleteUser()
Permanently deletes the identified user's record from People Analytics.java.lang.String
getDistinctId()
Deprecated.in 6.2.0 NOTE: This method is deprecated.void
identify(java.lang.String distinctId)
Deprecated.in 6.2.0 NOTE: This method is deprecated.void
increment(java.lang.String name, double increment)
Add the given amount to an existing property on the identified user.void
increment(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
Change the existing values of multiple People Analytics properties at once.boolean
isIdentified()
Checks if the people profile is identified or not.void
merge(java.lang.String name, org.json.JSONObject updates)
Merge a given JSONObject into the object-valued property named name.void
remove(java.lang.String name, java.lang.Object value)
Remove value from a list-valued property only if they are already present in the list.void
set(java.lang.String propertyName, java.lang.Object value)
Sets a single property with the given name and value for this user.void
set(org.json.JSONObject properties)
Set a collection of properties on the identified user all at once.void
setMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Set a collection of properties on the identified user all at once.void
setOnce(java.lang.String propertyName, java.lang.Object value)
Works just likeset(String, Object)
, except it will not overwrite existing property values.void
setOnce(org.json.JSONObject properties)
Likeset(String, Object)
, but will not set properties that already exist on a record.void
setOnceMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Likeset(String, Object)
, but will not set properties that already exist on a record.void
trackCharge(double amount, org.json.JSONObject properties)
Track a revenue transaction for the identified people profile.void
union(java.lang.String name, org.json.JSONArray value)
Adds values to a list-valued property only if they are not already present in the list.void
unset(java.lang.String name)
permanently removes the property with the given name from the user's profileMixpanelAPI.People
withIdentity(java.lang.String distinctId)
Return an instance of Mixpanel people with a temporary distinct id.
-
-
-
Method Detail
-
identify
@Deprecated void identify(java.lang.String distinctId)
Deprecated.in 6.2.0 NOTE: This method is deprecated. Please useMixpanelAPI.identify(String)
instead.- Parameters:
distinctId
- a String that uniquely identifies the user. Users identified with the same distinct id will be considered to be the same user in Mixpanel, across all platforms and devices. We recommend choosing a distinct id that is meaningful to your other systems (for example, a server-side account identifier)- See Also:
MixpanelAPI.identify(String)
-
set
void set(java.lang.String propertyName, java.lang.Object value)
Sets a single property with the given name and value for this user. The given name and value will be assigned to the user in Mixpanel People Analytics, possibly overwriting an existing property with the same name.- Parameters:
propertyName
- The name of the Mixpanel property. This must be a String, for example "Zip Code"value
- The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
-
setMap
void setMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Set a collection of properties on the identified user all at once.- Parameters:
properties
- a Map containing the collection of properties you wish to apply to the identified user. Each key in the Map will be associated with a property name, and the value of that key will be assigned to the property. See alsoset(org.json.JSONObject)
-
set
void set(org.json.JSONObject properties)
Set a collection of properties on the identified user all at once.- Parameters:
properties
- a JSONObject containing the collection of properties you wish to apply to the identified user. Each key in the JSONObject will be associated with a property name, and the value of that key will be assigned to the property.
-
setOnce
void setOnce(java.lang.String propertyName, java.lang.Object value)
Works just likeset(String, Object)
, except it will not overwrite existing property values. This is useful for properties like "First login date".- Parameters:
propertyName
- The name of the Mixpanel property. This must be a String, for example "Zip Code"value
- The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
-
setOnceMap
void setOnceMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Likeset(String, Object)
, but will not set properties that already exist on a record.- Parameters:
properties
- a Map containing the collection of properties you wish to apply to the identified user. Each key in the Map will be associated with a property name, and the value of that key will be assigned to the property. See alsosetOnce(org.json.JSONObject)
-
setOnce
void setOnce(org.json.JSONObject properties)
Likeset(String, Object)
, but will not set properties that already exist on a record.- Parameters:
properties
- a JSONObject containing the collection of properties you wish to apply to the identified user. Each key in the JSONObject will be associated with a property name, and the value of that key will be assigned to the property.
-
increment
void increment(java.lang.String name, double increment)
Add the given amount to an existing property on the identified user. If the user does not already have the associated property, the amount will be added to zero. To reduce a property, provide a negative number for the value.- Parameters:
name
- the People Analytics property that should have its value changedincrement
- the amount to be added to the current value of the named property- See Also:
increment(Map)
-
merge
void merge(java.lang.String name, org.json.JSONObject updates)
Merge a given JSONObject into the object-valued property named name. If the user does not already have the associated property, an new property will be created with the value of the given updates. If the user already has a value for the given property, the updates will be merged into the existing value, with key/value pairs in updates taking precedence over existing key/value pairs where the keys are the same.- Parameters:
name
- the People Analytics property that should have the update merged into itupdates
- a JSONObject with keys and values that will be merged into the property
-
increment
void increment(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
Change the existing values of multiple People Analytics properties at once.If the user does not already have the associated property, the amount will be added to zero. To reduce a property, provide a negative number for the value.
- Parameters:
properties
- A map of String properties names to Long amounts. Each property associated with a name in the map will have its value changed by the given amount- See Also:
increment(String, double)
-
append
void append(java.lang.String name, java.lang.Object value)
Appends a value to a list-valued property. If the property does not currently exist, it will be created as a list of one element. If the property does exist and doesn't currently have a list value, the append will be ignored.- Parameters:
name
- the People Analytics property that should have it's value appended tovalue
- the new value that will appear at the end of the property's list
-
union
void union(java.lang.String name, org.json.JSONArray value)
Adds values to a list-valued property only if they are not already present in the list. If the property does not currently exist, it will be created with the given list as it's value. If the property exists and is not list-valued, the union will be ignored.- Parameters:
name
- name of the list-valued property to set or modifyvalue
- an array of values to add to the property value if not already present
-
remove
void remove(java.lang.String name, java.lang.Object value)
Remove value from a list-valued property only if they are already present in the list. If the property does not currently exist, the remove will be ignored. If the property exists and is not list-valued, the remove will be ignored.- Parameters:
name
- the People Analytics property that should have it's value removed fromvalue
- the value that will be removed from the property's list
-
unset
void unset(java.lang.String name)
permanently removes the property with the given name from the user's profile- Parameters:
name
- name of a property to unset
-
trackCharge
void trackCharge(double amount, org.json.JSONObject properties)
Track a revenue transaction for the identified people profile.- Parameters:
amount
- the amount of money exchanged. Positive amounts represent purchases or income from the customer, negative amounts represent refunds or payments to the customer.properties
- an optional collection of properties to associate with this transaction.
-
clearCharges
void clearCharges()
Permanently clear the whole transaction history for the identified people profile.
-
deleteUser
void deleteUser()
Permanently deletes the identified user's record from People Analytics.Calling deleteUser deletes an entire record completely. Any future calls to People Analytics using the same distinct id will create and store new values.
-
isIdentified
boolean isIdentified()
Checks if the people profile is identified or not.- Returns:
- Whether the current user is identified or not.
-
getDistinctId
@Deprecated java.lang.String getDistinctId()
Deprecated.in 6.2.0 NOTE: This method is deprecated. Please useMixpanelAPI.getDistinctId()
instead.Returns the string id currently being used to uniquely identify the user associated with events sent usingset(String, Object)
andincrement(String, double)
. If no calls toMixpanelAPI.identify(String)
have been made, this method will return null.- Returns:
- The distinct id associated with updates to People Analytics
- See Also:
identify(String)
,MixpanelAPI.getDistinctId()
-
withIdentity
MixpanelAPI.People withIdentity(java.lang.String distinctId)
Return an instance of Mixpanel people with a temporary distinct id.- Parameters:
distinctId
- Unique identifier (distinct_id) that the people object will have- Returns:
- An instance of
MixpanelAPI.People
with the specified distinct_id
-
-