To identify users with the JustOneCX SDK, call identify(userId, traits) after the user signs in, group(accountId, traits) to set their account, and reset() when they sign out. Traits are properties such as plan or role that merge into the profile. Add a userHash from your server so nobody can claim another person's id.
What does identify() do?
identify() tells JustOneCX who the current user is.
identify ( "user-42" , { role : "admin" , plan : "growth" } ) ;
Enter fullscreen mode
Exit fullscreen mode
Traits merge into what the user already has. Call it on every page load after login, not only on the login event, to keep traits fresh. The order relative to init() does not matter. A call made before init() is queued and runs when init() does.
The signature is:
function identify ( userId : string , traits ?: Traits , options ?: { userHash ?: string } ) : Promise < void > ;
Enter fullscreen mode
Exit fullscreen mode
The promise resolves when the backend has saved the traits. It never rejects.β¦