After integrating Intercom into my app, I found that I need to call window.Intercom('update');
every time the URL changes.
Instead of adding this call in the mounted()
method for each component, I prefer to utilize navigation guards to avoid repetitive code in multiple places.
Currently, I have the following setup:
router.afterEach((to, from) => {
eventHub.$off(); // This is for other purposes not related here
console.log(window.location.href); // This logs the previous URL
window.Intercom('update'); // Which means it also uses the previous URL
})
This implementation triggers intercom('update')
before the URL change, while I require it to happen after the URL has been updated.
Is there a specific hook that executes only when the URL has changed? How can I achieve this?
Thank you!