devrnt / react-use-intercom

☎️ React Intercom integration without the hassle, powered by hooks.
https://devrnt.github.io/react-use-intercom/#/useIntercom
MIT License
337 stars 43 forks source link

User Hash Property / Formatting #668

Closed SandboxRD closed 8 months ago

SandboxRD commented 8 months ago

Issue Description In order to properly implement Identity Verification, Intercom requires a user_hash property to be passed on boot along with an identifier that was hashed (either user_id or email). In addition to passing along the identifier, the hashed identifier needs to be passed as user_hash .

Unfortunately, I'm only able to pass "userHash" in camel case instead of "user_hash" due to the way the DataAttributes type is defined in this library.

The end result is I'm able to produce the correct hash, but because it is being assigned to the incorrect property, Intercom is recognizing it as an invalid hash.

Relevant Links This would appear to need to be corrected in multiple places:

https://github.com/devrnt/react-use-intercom/blob/5b74e8a6e380907e8ced295c8e8b7bff726b5902/packages/react-use-intercom/src/mappers.ts#L69

https://github.com/devrnt/react-use-intercom/blob/5b74e8a6e380907e8ced295c8e8b7bff726b5902/packages/react-use-intercom/src/types.ts#L200

https://github.com/devrnt/react-use-intercom/blob/5b74e8a6e380907e8ced295c8e8b7bff726b5902/apps/playground/src/modules/useIntercom/useIntercom.tsx#L97

Expected behavior Once adjusted, the hash should be accepted as valid by Intercom.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

devrnt commented 8 months ago

Thank you for providing this detailed description.

The issue you have raised appears to be invalid. Indeed, the API of this library utilizes camel-cased attributes[^*] (a design choice that, in retrospect, I regret). However, it is essential to note that internally, these camel-cased attributes are mapped to their corresponding official Intercom attributes. You can find further details on this mapping process at https://github.com/devrnt/react-use-intercom/blob/main/packages/react-use-intercom/src/mappers.ts#L69.

Let me know if you need anything else.

[^*]: except for the entries that are passed to customAttributes