User Identifier and Property

๐Ÿ“˜

Managing User Identifiers

User identifiers are used to uniquely identify users. For information on the meaning, importance, and criteria for choosing user identifiers, please refer to the Managing User Identifiers documentation.

Using Managed Identifiers in the SDK

The React Native SDK includes functionality to manage device identifiers. Therefore, you can automatically identify users without explicitly providing user identifiers.

You can obtain managed identifiers in the SDK as follows:

// Get the internally managed device identifier
const deviceId = getDeviceId();

Adding User Identifiers

You can set the identifier of a logged-in user. If you manage the device identifier separately, you can set it separately.

Example

// 1. Set the identifier of the logged-in user
hackleClient.setUserId("LOGIN_ID");

// 2. Change the device identifier
hackleClient.setDeviceId("CUSTOM_DEVICE_ID");

Additional Identifiers

You can send additional identifiers other than the default identifiers using the example code below.

const user = {
  userId: "LOGIN_ID", // User ID (Hackle unified identifier can be used)
  deviceId: "CUSTOM_DEVICE_ID", // Device ID (Hackle unified identifier can be used)
  identifiers: {
    myCustomId: "CUSTOM_IDENTIFIER" // Custom ID
  }
};

hackleClient.setUser(user);

Properties

Hackle SDK supports adding properties to a User object.

  • Properties must be sent as a pair with both property name (key) and a property value (value).
  • The maximum number of properties that can be added to a User object is 64.

Property Key (Name)

  • The key should be set as a general name, but easily identifiable.
  • The character limit is 64 characters.
  • It is not case sensitive. For example, AGE and age are recognized as the same key.

Property Value

  • The value supports boolean, string, and number types.
  • In the case of string type, the character limit is 64 characters.
  • The string type is case-sensitive. For example, APPLE and apple are recognized as different property values.
  • In the case of number type, up to 15 integers and up to 6 decimal places are supported.

Setting User Properties

You can add or remove user properties.

To set user properties, instantiate a PropertyOperations object with the properties you want to set. Then, call updateUserProperties to update the user properties. You can set multiple properties at once.

const operations = new PropertyOperationsBuilder()
  .set("age", 42)
  .set("grade", "GOLD")
  .setOnce("sign_up_date", "2020-07-03")
  .build();

hackleClient.updateUserProperties(operations);

set

Set user properties. It overrides the existing property value with the specified value.

const operations = new PropertyOperationsBuilder()
    .set("age", 42)
    .set("grade", "GOLD")
    .build();

hackleClient.updateUserProperties(operations);

setOnce

Set user properties with a value that can be set only once. If a property key already exists, setOnce is ignored. For example, you can set properties like the signup date and initial location for a user.

const operations = new PropertyOperationsBuilder()
  .setOnce("sign_up_date", "2020-07-03")
  .setOnce("initial_location", "Seoul")
  .build();

hackleClient.updateUserProperties(operations);

unset

Remove the specified user properties.

const operations = new PropertyOperationsBuilder()
  .unset("membership_type")
  .build();

hackleClient.updateUserProperties(operations);

clearAll

Remove all user properties.

const operations = new PropertyOperationsBuilder()        
  .clearAll()
  .build();

hackleClient.updateUserProperties(operations);

Resetting User Properties

When a user logs out, you need to reset the previously set information. You can do this by calling the following method:

hackleClient.resetUser();

When you call resetUser(), all previously set identifiers and properties are reset.