diff options
-rw-r--r-- | track.js | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -13,6 +13,7 @@ }, 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({ @@ -20,7 +21,7 @@ "referrer": document.referrer, "startedAt": startedAt, "timeSpent": Math.floor((new Date() - startedAt) / 1000), - "scrolledTo": scrolledTo / document.scrollingElement.scrollHeight + "scrolledTo": (scrolledTo || 0) / document.scrollingElement.scrollHeight })) }) })() |