analytics/priv/tracker/js/plausible.hash.js

1 line
1.2 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e,a=window.location,r=window.document,t=window.localStorage,o=r.currentScript,l=o.getAttribute("data-api")||new URL(o.src).origin+"/api/event",s=t&&t.plausible_ignore;function w(e){console.warn("Ignoring Event: "+e)}function i(e,t){if(/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(a.hostname)||"file:"===a.protocol)return w("localhost");if(!(window.phantom||window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)){if("true"==s)return w("localStorage flag");var i={};i.n=e,i.u=a.href,i.d=o.getAttribute("data-domain"),i.r=r.referrer||null,i.w=window.innerWidth,t&&t.meta&&(i.m=JSON.stringify(t.meta)),t&&t.props&&(i.p=JSON.stringify(t.props)),i.h=1;var n=new XMLHttpRequest;n.open("POST",l,!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(i)),n.onreadystatechange=function(){4==n.readyState&&t&&t.callback&&t.callback()}}}function n(){e=a.pathname,i("pageview")}window.addEventListener("hashchange",n);var d=window.plausible&&window.plausible.q||[];window.plausible=i;for(var c=0;c<d.length;c++)i.apply(this,d[c]);"prerender"===r.visibilityState?r.addEventListener("visibilitychange",function(){e||"visible"!==r.visibilityState||n()}):n()}();