diff --git a/shynet/analytics/templates/analytics/scripts/page.js b/shynet/analytics/templates/analytics/scripts/page.js index 569f463..ab121e4 100644 --- a/shynet/analytics/templates/analytics/scripts/page.js +++ b/shynet/analytics/templates/analytics/scripts/page.js @@ -3,18 +3,25 @@ window.onload = function () { Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); function sendUpdate() { - var xhr = new XMLHttpRequest(); - xhr.open("POST", self.location.protocol + "//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}", true); - xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send( - JSON.stringify({ - idempotency: idempotency, - referrer: document.referrer, - loadTime: - window.performance.timing.domContentLoadedEventEnd - - window.performance.timing.navigationStart, - }) - ); + try { + var xhr = new XMLHttpRequest(); + xhr.open( + "POST", + self.location.protocol + + "//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}", + true + ); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send( + JSON.stringify({ + idempotency: idempotency, + referrer: document.referrer, + loadTime: + window.performance.timing.domContentLoadedEventEnd - + window.performance.timing.navigationStart, + }) + ); + } catch {} } setInterval(sendUpdate, 5000); sendUpdate();