analytics/priv/tracker/js/plausible.compat.dimensions.exclusions.local.manual.outbound-links.js
RobertJoonas 199206babc
Dimensions continued (#1847)
* added the first version of dimensions extension

* finished dimensions script extension + updated tracking to use it

* script variants build
2022-04-25 10:56:11 +03:00

1 line
1.8 KiB
JavaScript

!function(){"use strict";var e,t,a,l=window.location,u=window.document,c=u.getElementById("plausible"),p=c.getAttribute("data-api")||(e=c.src.split("/"),t=e[0],a=e[2],t+"//"+a+"/api/event"),s=c&&c.getAttribute("data-exclude").split(",");function d(e){console.warn("Ignoring Event: "+e)}function r(e,t){if(!(window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)){try{if("true"===window.localStorage.plausible_ignore)return d("localStorage flag")}catch(e){}if(s)for(var a=0;a<s.length;a++)if("pageview"===e&&l.pathname.match(new RegExp("^"+s[a].trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$")))return d("exclusion rule");var r={};r.n=e,r.u=t&&t.u?t.u:l.href,r.d=c.getAttribute("data-domain"),r.r=u.referrer||null,r.w=window.innerWidth,t&&t.meta&&(r.m=JSON.stringify(t.meta)),t&&t.props&&(r.p=t.props);var n=c.getAttributeNames().filter(function(e){return"event-"===e.substring(0,6)}),i=r.p||{};n.forEach(function(e){var t=e.replace("event-",""),a=c.getAttribute(e);i[t]=i[t]||a}),r.p=i;var o=new XMLHttpRequest;o.open("POST",p,!0),o.setRequestHeader("Content-Type","text/plain"),o.send(JSON.stringify(r)),o.onreadystatechange=function(){4===o.readyState&&t&&t.callback&&t.callback()}}}function n(e){for(var t=e.target,a="auxclick"===e.type&&2===e.which,r="click"===e.type;t&&(void 0===t.tagName||"a"!==t.tagName.toLowerCase()||!t.href);)t=t.parentNode;t&&t.href&&t.host&&t.host!==l.host&&((a||r)&&plausible("Outbound Link: Click",{props:{url:t.href}}),t.target&&!t.target.match(/^_(self|parent|top)$/i)||e.ctrlKey||e.metaKey||e.shiftKey||!r||(setTimeout(function(){l.href=t.href},150),e.preventDefault()))}u.addEventListener("click",n),u.addEventListener("auxclick",n);var i=window.plausible&&window.plausible.q||[];window.plausible=r;for(var o=0;o<i.length;o++)r.apply(this,i[o])}();