User Identifier & Properties
User Identifier
Default Identifiers Provided by Hackle
The JavaScript SDK includes functionality for managing device identifiers. Therefore, users can be identified automatically without providing a separate user identifier.
You can retrieve the identifier managed by the SDK as follows.
// 사용자 정보 가지고 오기
const user = await hackleClient.getUser();
// 디바이스 식별자 가져오기
const deviceId = getDeviceId();Modifying Device ID
You can inject a custom device ID instead of using the device ID provided by Hackle.
// 디바이스 식별자 변경
await hackleClient.setDeviceId("CUSTOM_DEVICE_ID");Setting User Identifier (User ID)
You can set the identifier for a logged-in user.
Additional Identifiers
To add identifier types other than the default identifiers (deviceId, userId), configure them as shown below.
Using setUser overwrites the user information on the current device.
If you are currently using user ID A and call
setUserwithout passing user ID A, the userId changes from A to null.If you are currently using a custom deviceId and call
setUserwithout passing the current deviceId, the custom deviceId reverts to the Hackle deviceId.If you are using additional identifiers and call
setUserwithout passing them, the additional identifiers are reset.For properties, the cached properties on the device may be retained or cleared based on the following cases:
If userId and deviceId are the same before and after
setUser, cached properties are retained.If userId or deviceId changes before and after
setUser, cached properties are deleted.
User Properties
The Hackle SDK supports adding user properties.
Properties must be sent as key-value pairs (Property Key and Property Value).
The maximum number of properties that can be added is 128.
Property Key
string
Character limit is 128 characters.
Case-insensitive.
For example, AGE and age are recognized as the same Property Key.
Property Value
boolean, string, number, array
For string type, the character limit is 1024 characters.
String type is case-sensitive.
For example, APPLE and apple are recognized as different Property Values.
For number type, up to 15 integer digits and up to 6 decimal places are supported.
Adding User Properties
You can add user properties simply. Calling the function below behaves the same as adding a property using set in a PropertyOperations object.
Configuring User Properties
You can add or remove user properties.
set
Sets a User Property. If a Property Value already exists for the Property Key, it is overwritten.
setOnce
Sets a User Property value only once. If a property already exists for the Property Key, it is ignored.
For example, you can use this to set a user's registration date or initial sign-up location.
unset
Removes a User Property.
clearAll
Removes all User Properties.
Instantiate a PropertyOperationsBuilder object with the user properties you want to configure. Then call updateUserProperties to update the user properties. You can also configure multiple properties at once.
Resetting User
You must reset the previously configured information. Resetting clears all identifiers and properties that were previously set.
Resetting the user also clears all user properties stored on the server. If you want to handle logout, use hackleClient.setUserId(undefined);.
Assigning undefined to userId performs a client-side logout.
Last updated