mirror of
https://github.com/plausible/analytics.git
synced 2025-01-08 02:56:58 +03:00
fbd6e37767
* Add option to specify a URL in the manual extension * Fix error when option parameter isn't provided The uglify-js dependency had to be updated to support the optional chaining operator * Remove the possibility to pass a function for the custom URL This added weight unnecessarily, as the users can simply call the function themselves before triggering the event. * Change optional chaining to ternary for improved browser support * Revert package-lock.json to version 3.9.4 of uglify-js It was previously updated to support optional chaining; reverting it as a reminder that this is the current browser support level that is accepted by Plausible.
1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
!function(){"use strict";var a=window.location,o=window.document,e=window.localStorage,l=o.currentScript,w=l.getAttribute("data-api")||new URL(l.src).origin+"/api/event",p=e&&e.plausible_ignore,u=l&&l.getAttribute("data-exclude").split(",");function d(e){console.warn("Ignoring Event: "+e)}function t(e,t){if(!(window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)){if("true"==p)return d("localStorage flag");if(u)for(var n=0;n<u.length;n++)if("pageview"==e&&a.pathname.match(new RegExp("^"+u[n].trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$")))return d("exclusion rule");var i={};i.n=e,i.u=t&&t.u?t.u:a.href,i.d=l.getAttribute("data-domain"),i.r=o.referrer||null,i.w=window.innerWidth,t&&t.meta&&(i.m=JSON.stringify(t.meta)),t&&t.props&&(i.p=JSON.stringify(t.props));var r=new XMLHttpRequest;r.open("POST",w,!0),r.setRequestHeader("Content-Type","text/plain"),r.send(JSON.stringify(i)),r.onreadystatechange=function(){4==r.readyState&&t&&t.callback&&t.callback()}}}var n=window.plausible&&window.plausible.q||[];window.plausible=t;for(var i=0;i<n.length;i++)t.apply(this,n[i])}(); |