devrnt / react-use-intercom

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

Change last_requested_at to last_request_at #609

Closed rorhug closed 1 year ago

rorhug commented 1 year ago

The attribute to do a "page view" update (without user attribute changes) is last_request_at, rather than last_requested_at. This translates to the default attribute in the Intercom UI "Last Seen" (source)

Also, the attribute takes seconds rather than milliseconds.

Here's the documentation which talks about doing page view updates: https://www.intercom.com/help/en/articles/170-integrate-intercom-in-a-single-page-app


With the current version of this package, user objects in Intercom have the following invalid attribute: Screenshot 2023-01-28 at 18 43 33

devrnt commented 1 year ago

Hi, thanks for your PR. Can you take a look at the failed build? I definitely want to merge it

rorhug commented 1 year ago

Added number to the time types. Docs: https://www.intercom.com/help/en/articles/3605703-how-dates-work-in-intercom

Intercom accepts any of the following for a datetime:

"2023-01-30T11:28:45.181Z" "1675078024647" 1675078024647

Hence why I'm suggesting created_at and last_request_at take a string | number

rorhug commented 1 year ago

Thanks for trying to fix it - I wasn't able to run the checks.

I think we need parseInt to floor the number as recommended in the intercom docs. The errors from the a98be4b commit were for assigning a number to a string.

parseInt takes a number and returns a number so should probably be included and instead the number type should be added in another type def.

rorhug commented 1 year ago

My bad! parseInt only takes a string according to typescript so switched it to math.floor.

This version typescript compiles I think now.

devrnt commented 1 year ago

Thanks, can you sync with the upstream please?

devrnt commented 1 year ago

FYI: the upstream main branch was renamed from master to main

devrnt commented 1 year ago

v3.0.2