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

Cannot use snake cased args (for non-custom Intercom props) #16

Closed queengooborg closed 4 years ago

queengooborg commented 4 years ago

During migration from react-intercom, we ran into another little issue with variable names. As described, all of Intercom's default props are camel cased, however there are implications that snake casing is allowed. However, when I tried to pass user_hash, it apparently was not passed to Intercom. It seems that in mapDataAttributesToRawDataAttributes(), user_hash is overwritten by whatever userHash is.

devrnt commented 4 years ago

@vinyldarkscratch Thanks for your issue. It seems like this is expected behaviour. As mentioned all the possible attributes that are given on https://developers.intercom.com/installing-intercom/docs/javascript-api-attributes-objects will be typed camel cased.

Will add the bug label until #17 gets fixed.

queengooborg commented 4 years ago

I feel that it would make sense to allow for snake casing (either allowing both or solely going for snake casing) for the primary reason that Intercom's built-in variables are all snake cased. Another part is probably that the docs don't make it particularly clear that the props have to be camel-cased -- the part stating "No need to pass the props with snake_cased keys" has implication that snake casing is allowed.

Since we're now depending on this module for our project, I'll see if I can get something written up in a PR!