Menu

Set User Property

SolarEngine provides multiple methods for reporting user properties. You can use these methods to add or modify user properties.

It is recommended for you to select properties that change infrequently or hold significant value, for example, age, game level, location, first payment time and total payment amount. Other properties with higher change frequency can be reported and recorded through events.

User property settings can be set by calling userUpdate, userInit, userAdd, userUnset, userAppend, or userDelete.

Note:

  1. The format requirements of user properties are consistent with those of event properties.
  2. Please do not report properties whose keys start with an underscore "_". The SDK will discard properties like this by default.

1. userInit

   If you want to upload a batch of user attributes, among which the existing user attributes will not update their values, and the non-existing attributes will be created and saved, you can call userInit to set them.

Function

public synchronized void userInit(JSONObject properties);
ParameterDescriptionTypeRequired
propertiesDeveloper custom user properties JSONObject Yes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;
import org.json.JSONObject;

JSONObject properties = new JSONObject();
try {
    //Developer custom event properties in JSON format
    properties.put("userName","xiaoming");
    properties.put("userLevel","1");
} catch (JSONException e) {
///
}

SolarEngineManager.getInstance().userInit(properties);

2. userUpdate

   For general user attributes, you can call userUpdate to set them. The attributes uploaded in this way will overwrite the original attribute values. If the user attribute does not exist before, it will be created, and the data type will follow the value passed in.

Function

public synchronized void userUpdate(JSONObject properties);
ParameterDescriptionTypeRequired
propertiesDeveloper custom user propertiesJSONObjectYes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;
import org.json.JSONObject;

JSONObject properties = new JSONObject();
try {
    //Developer custom event properties in JSON format
    properties.put("userName","lilei");
    properties.put("userLevel","10");
} catch (JSONException e) {
///
}

SolarEngineManager.getInstance().userUpdate(properties);

3. userAdd

   If you want to report a numeric attribute and accumulate its values, you can call userAdd. If the attribute has not been set, it will be assigned a value of 0 and then calculated. You can pass in a negative value, which is equivalent to a subtraction operation.

Function

public synchronized void userAdd(JSONObject properties);
ParameterDescriptionTypeRequired
propertiesDeveloper custom user propertiesJSONObjectYes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;
import org.json.JSONObject;

JSONObject properties = new JSONObject();
try {
    //Developer custom event properties in JSON format
    properties.put("totalRevenue",40);
    properties.put("totalGoodsNum",20);
} catch (JSONException e) {
///
}

SolarEngineManager.getInstance().userAdd(properties);

Note:

   The value called by userAdd only allows Number type.

4. userUnset

   When you want to clear the user attribute values of a user, you can call userUnset to clear the specified attributes (string array). If the attribute has not been created in the array, the attribute will not be created.

Function

public synchronized void userUnset(String... keys) {
ParameterDescriptionTypeRequired
keysCustom property keyStringYes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;

String[] keys = new String[]{"userName","userLevel"};
SolarEngineManager.getInstance().userUnset(keys);

5. userAppend

   You can call userAppend to append user attributes of array type. If the attribute does not exist, it will be created.

Function

public synchronized void userAppend(JSONObject properties);
ParameterDescriptionTypeRequired
propertiesDeveloper custom user propertiesJSONObjectYes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;
import org.json.JSONObject;
import org.json.JSONObject;

JSONObject properties = new JSONObject();
JSONArray goodsList = new JSONArray();

try {
    //Developer custom event properties in JSON format
    goodsList.put("trousers");
    goodsList.put("shoes");
    goodsList.put("cap");
    properties.put("goodsList",goodsList);
} catch (JSONException e) {
///
}

SolarEngineManager.getInstance().userAppend(properties);

6. userDelete

   You can call userDelete to delete users. After a user is deleted, you will no longer be able to query the user's user attributes, but the events generated by the user can still be queried.

Function

public synchronized void userDelete(SEUserDeleteType seUserDeleteType);
ParameterDescriptionTypeRequired
seUserDeleteTypeHow to delete a user, e.g.
SEUserDeleteTypeByAccountId: Delete a user by Account ID
SEUserDeleteTypeByVisitorId: Delete a user by Visitor ID
SEUserDeleteType Yes

Sample Code

import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().userDelete(SEUserDeleteType.DELETE_BY_ACCOUNTID);


Previous
Event Reporting
Next
First Time Event
Last modified: 2024-12-03Powered by