Closed flore2003 closed 7 years ago
I'll work on this today, thanks for the request!
Released 1.0.0-beta.1 with a new option updateOnRouterChange
. Set it to true
to automatically handle router events.
Just a heads up, you nessecarily don't have to log to intercom on a route change in a spa, they watch window.location. Unless you are bypassing the angular routers native functionality to perhaps add something like query strings or something using the navigator and ignoring the history API. Still a cool feature, but it can double log an event, so it's best to use with caution.
@scott-wyatt Could you point me to where this is stated? I've looked through the documentation but could not find mention of this behavior.
Good note @scott-wyatt, can you add that to the docs?
@flore2003 I was just going through their docs and it says it does require you to send an Itercom.update, which is odd, because I don't do that but still see the current page in intercom despite not doing that in my sample apps. In the plugins code, it looks like it is listening for changes in the browser history API, so it would stand to reason that they are listening to it, but that it is not documented, not their preferred method, or that their documentation may be out of date?
I think this is just a safe option for those who want to follow the API docs. This is definitely a feature I like having.
Usually, Intercom track the user on their journey through the app using page loads. However, when using Intercom with a SPA, the user navigation is not automatically recorded, rather, the Intercom JavaScript SDK provides an update method that can be called whenever the URL changes without a real page load to tell Intercom that the user has navigated (https://developers.intercom.com/v2.0/docs/integrate-intercom-in-a-single-page-app)
It would be a nice addition to this library to automatically listen for Router events and send the update pings to Intercom, whenever the user navigates in the app. It would be probably best to make this an optional behavior that can be turned on using some kind of configuration flag.