Ability to unregister umami

This commit is contained in:
Bartosz Hernas 2020-09-14 18:13:59 +02:00
parent 8727dbf282
commit 2ea91aaabf
2 changed files with 15 additions and 5 deletions

View file

@ -73,8 +73,8 @@ import { removeTrailingSlash } from '../lib/url';
pageView();
};
history.pushState = hook(history, 'pushState', handlePush);
history.replaceState = hook(history, 'replaceState', handlePush);
const pushStateUnhook = hook(history, 'pushState', handlePush);
const replaceStateUnhook = hook(history, 'replaceState', handlePush);
/* Handle events */
@ -106,4 +106,12 @@ import { removeTrailingSlash } from '../lib/url';
if (!window.umami) {
window.umami = event_value => collect('event', { event_type: 'custom', event_value });
}
if (!window.umamiUnregister) {
window.umamiUnregister = () => {
pushStateUnhook();
replaceStateUnhook();
removeEvents();
};
}
})(window);