mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +01:00
Update tracker script.
This commit is contained in:
parent
44d1704b21
commit
b1d8a58e22
@ -133,26 +133,24 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
/* Handle history changes */
|
/* Handle history changes */
|
||||||
|
|
||||||
const handlePush = (state, title, url) => {
|
const handlePush = (state, title, url) => {
|
||||||
removeEvents();
|
if (!url) return;
|
||||||
// url is not guaranteed
|
|
||||||
// thus calling `url.toString()` might causes exception, then break the pjax update
|
|
||||||
// track only if url is validate
|
|
||||||
if (url) {
|
|
||||||
currentRef = currentUrl;
|
|
||||||
const newUrl = url.toString();
|
|
||||||
|
|
||||||
if (newUrl.substring(0, 4) === 'http') {
|
removeEvents();
|
||||||
currentUrl = '/' + newUrl.split('/').splice(3).join('/');
|
|
||||||
} else {
|
currentRef = currentUrl;
|
||||||
currentUrl = newUrl;
|
const newUrl = url.toString();
|
||||||
}
|
|
||||||
// this function under some framework might be called multiple times
|
if (newUrl.substring(0, 4) === 'http') {
|
||||||
// thus only track if currentUrl and currentRef are not same
|
currentUrl = '/' + newUrl.split('/').splice(3).join('/');
|
||||||
if (currentUrl !== currentRef) {
|
} else {
|
||||||
trackView(currentUrl, currentRef);
|
currentUrl = newUrl;
|
||||||
setTimeout(addEvents, 300);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentUrl !== currentRef) {
|
||||||
|
trackView(currentUrl, currentRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(addEvents, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Global */
|
/* Global */
|
||||||
|
Loading…
Reference in New Issue
Block a user