analytics/priv/tracker/js/plausible.compat.local.js
2021-09-23 11:16:19 +02:00

1 line
1.2 KiB
JavaScript

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