Improve script resiliency
This commit is contained in:
parent
d1c6d4ed52
commit
2fa5db362a
@ -3,18 +3,25 @@ window.onload = function () {
|
|||||||
Math.random().toString(36).substring(2, 15) +
|
Math.random().toString(36).substring(2, 15) +
|
||||||
Math.random().toString(36).substring(2, 15);
|
Math.random().toString(36).substring(2, 15);
|
||||||
function sendUpdate() {
|
function sendUpdate() {
|
||||||
var xhr = new XMLHttpRequest();
|
try {
|
||||||
xhr.open("POST", self.location.protocol + "//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}", true);
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.setRequestHeader("Content-Type", "application/json");
|
xhr.open(
|
||||||
xhr.send(
|
"POST",
|
||||||
JSON.stringify({
|
self.location.protocol +
|
||||||
idempotency: idempotency,
|
"//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
|
||||||
referrer: document.referrer,
|
true
|
||||||
loadTime:
|
);
|
||||||
window.performance.timing.domContentLoadedEventEnd -
|
xhr.setRequestHeader("Content-Type", "application/json");
|
||||||
window.performance.timing.navigationStart,
|
xhr.send(
|
||||||
})
|
JSON.stringify({
|
||||||
);
|
idempotency: idempotency,
|
||||||
|
referrer: document.referrer,
|
||||||
|
loadTime:
|
||||||
|
window.performance.timing.domContentLoadedEventEnd -
|
||||||
|
window.performance.timing.navigationStart,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
setInterval(sendUpdate, 5000);
|
setInterval(sendUpdate, 5000);
|
||||||
sendUpdate();
|
sendUpdate();
|
||||||
|
Loading…
Reference in New Issue
Block a user