summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--track.js6
1 files changed, 1 insertions, 5 deletions
diff --git a/track.js b/track.js
index 5b0e544..cc2df6f 100644
--- a/track.js
+++ b/track.js
@@ -12,11 +12,7 @@
scrolledTo = Math.max(scrolledTo, window.scrollY + window.innerHeight)
}, false)
window.addEventListener("beforeunload", ()=>{
- let xhr = new XMLHttpRequest()
- startedAt = startedAt || new Date()
- xhr.open("POST", "https://stats.ignore.pl/entry")
- xhr.setRequestHeader("Content-Type", "application/json")
- xhr.send(JSON.stringify({
+ navigator.sendBeacon("https://stats.ignore.pl/entry", JSON.stringify({
"location": document.location.href,
"referrer": document.referrer,
"startedAt": startedAt,