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

1 line
1.5 KiB
JavaScript

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