-
Couldn't load subscription status.
- Fork 49
Description
Intercom is not booted before the first 'trackEvent' being called, despite having autoBoot configured and enabled.
When my application loads it initializes Intercom, with the IntercomProvider component, and in one of the children it calls trackEvent. That even never sent to Intercom and I can see the following warning on the console:
[react-use-intercom] "trackEvent" was called but Intercom has not booted yet. Please call 'boot' before calling 'trackEvent' or set 'autoBoot' to true in the IntercomProvider.
This started happening with version 5.4.1. On version 5.4.0 it still worked as expected.
I thought this could be related to #635, but that seems to have been reported before version 5.4.1 was released.
I can see that the changes in 5.4.1 (a6d7757) affect the initialization, namely putting the initialization in an effect.
My component which calls trackEvent also does so inside useEffect, so it runs before Intercom was booted in the effect of IntercomProvider.
Is there a better way of tracking an event as soon as the components are "ready"? Or is this an unintended consequence of the change?