mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 18:48:06 +03:00
a7eab3f17b
Fixes #1225
1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
!function(){"use strict";var e,a=window.location,r=window.document,i=window.localStorage,o=r.currentScript,w=o.getAttribute("data-api")||new URL(o.src).origin+"/api/event",d=i&&i.plausible_ignore;function n(e,i){var n,t;window.phantom||window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress||("true"!=d?((n={}).n=e,n.u=a.href,n.d=o.getAttribute("data-domain"),n.r=r.referrer||null,n.w=window.innerWidth,i&&i.meta&&(n.m=JSON.stringify(i.meta)),i&&i.props&&(n.p=JSON.stringify(i.props)),n.h=1,(t=new XMLHttpRequest).open("POST",w,!0),t.setRequestHeader("Content-Type","text/plain"),t.send(JSON.stringify(n)),t.onreadystatechange=function(){4==t.readyState&&i&&i.callback&&i.callback()}):console.warn("Ignoring Event: localStorage flag"))}function t(){e=a.pathname,n("pageview")}window.addEventListener("hashchange",t);var l=window.plausible&&window.plausible.q||[];window.plausible=n;for(var s=0;s<l.length;s++)n.apply(this,l[s]);"prerender"===r.visibilityState?r.addEventListener("visibilitychange",function(){e||"visible"!==r.visibilityState||t()}):t()}(); |