In the Android project I'm working on, we're noticing that user data is getting mixed up. Why could this be happening? Every time a user logs into the application, we perform a login to Intercom using the following code:
operator fun invoke(user: UserModel, intercomHash: String) {
val userAttributes = createUserAttributes(user)
val registration = Registration.create().withUserId(user.id)
Intercom.client().setUserHash(intercomHash)
Intercom.client().loginIdentifiedUser(registration, object : IntercomStatusCallback {
override fun onFailure(intercomError: IntercomError) {
/*
The Intercom login will fail with error code 3002 if the user is already logged in.
*/
}
override fun onSuccess() {
Intercom.client().updateUser(userAttributes)
}
})
}
private fun createUserAttributes(user: UserModel) = UserAttributes.Builder()
.withEmail(user.person.emailAddress)
.withPhone(user.person.phoneNumber)
.withName(user.person.name.fullName)
.withCustomAttribute(CUIT_CUIL, user.person.identification.cuitCuil)
.withCustomAttribute(FIRST_NAME, user.person.name.firstName)
.withCustomAttribute(LAST_NAME, user.person.name.lastName)
.withCustomAttribute(EMAIL, user.person.emailAddress)
.withCustomAttribute(DNI, user.person.identification.dni)
.withCustomAttribute(TRACKING_ID, user.trackingId)
.build()
And if the user unlinks their account, we use
Intercom.client().logout()
Please note that we're using version 15.1.0 of the Intercom SDK.