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.

User Identifiers

Use SDK-managed identifiers

The Android SDK includes features to automatically manage device identifiers. Therefore, the user can be automatically identified without having to manually pass the user identifier separately as a parameter.

Here's how to obtain the identifiers managed internally by the SDK:

// Retrieve the internally managed device ID
val deviceId = hackleApp.deviceId

// Retrieve the internally managed session ID
val sessionId = hackleApp.sessionId

// Retrieve the All the user information set
val user = hackleApp.user
// Retrieve the internally managed device ID
String deviceId = hackleApp.getDeviceId();

// Retrieve the internally managed session ID
String sessionId = hackleApp.getSessionId();

// Retrieve the All the user information set
User user = hackleApp.getUser();

Add User Identifier

You can set the identifier for a logged-in user. If you manage device identifiers separately, you can set them as well.

// 1. Send user ID of logged in user
hackleApp.setUserId("LOGIN_ID")

// 2. Change device ID
hackleApp.setDeviceId("CUSTOM_DEVICE_ID")
// 1. Send user ID of logged in user
hackleApp.setUserId("LOGIN_ID");

// 2. Change device ID
hackleApp.setDeviceId("CUSTOM_DEVICE_ID");

Use custom user identifiers you manage

You can set additional identifiers using the following code:

import io.hackle.sdk.common.User
  
val user = User.builder()
    .userId("143")                   // User ID (Hackle integrated identifier supported)
    .deviceId("ae2182e0")            // Device ID (Hackle integrated identifier supported)
    .identifier("myCustomId", "42")  // Custom ID
    .build()
  
hackleApp.setUser(user)
import io.hackle.sdk.common.User
  
User user = User.builder()
    .userId("143")                    // User ID (Hackle integrated identifier supported)
    .deviceId("ae2182e0")            // Device ID (Hackle integrated identifier supported)
    .identifier("myCustomId", "42")  // Custom ID
    .build();
  
hackleApp.setUser(user);

Property

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.

User Property Configuration

You can add or remove user properties.

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

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

hackleApp.updateUserProperties(operations);

set

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

PropertyOperations operations = PropertyOperations.builder()
    .set("age", 42)
    .set("grade", "GOLD")
    .build();

hackleApp.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.

PropertyOperations operations = PropertyOperations.builder()
    .setOnce("sign_up_date", "2020-07-03")
    .setOnce("initial_location", "Seoul")
    .build();

hackleApp.updateUserProperties(operations);

unset

Remove the specified user properties.

PropertyOperations operations = PropertyOperations.builder()
    .unset("membership_type")
    .build();

hackleApp.updateUserProperties(operations);

clearAll

Remove all user properties.

PropertyOperations operations = PropertyOperations.clearAll();

hackleApp.updateUserProperties(operations);