analytics/priv/tracker/js/p.js
Vignesh Joglekar 96633f46b1
Fixes exclude regex eating one character before single * (#861)
* Swaps to Negative Lookbehind for exclude Regex

* Updates to not use negative lookbehind
2021-03-22 15:44:53 +02:00

1 line
2.0 KiB
JavaScript

!function(r,a){"use strict";function o(e){console.warn("[Plausible] Ignoring event because "+e)}function l(){var e,i,t,n=JSON.parse((t="plausible_user",(t=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)")))?decodeURIComponent(t[1]):null));return n?{initial_referrer:n.initial_referrer&&decodeURIComponent(n.initial_referrer),initial_source:n.initial_source&&decodeURIComponent(n.initial_source)}:(n={initial_referrer:r.document.referrer||null,initial_source:getSourceFromQueryParam()},e="plausible_user",i=JSON.stringify({initial_referrer:n.initial_referrer&&encodeURIComponent(n.initial_referrer),initial_source:n.initial_source&&encodeURIComponent(n.initial_source)}),(t=new Date).setTime(t.getTime()+94608e6),t="; expires="+t.toUTCString(),document.cookie=e+"="+(i||"")+t+"; samesite=strict; path=/",n)}function i(e,i){if(/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(r.location.hostname))return o("website is running locally");if("file:"===r.location.protocol)return o("website is running locally");if("prerender"===r.document.visibilityState)return o("document is prerendering");var t=s.trackAcquisition?l():{};t.n=e,t.u=r.location.href,t.d=s.domain,t.r=r.document.referrer||null,t.w=r.innerWidth;var n=new XMLHttpRequest;n.open("POST",a+"/api/event",!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(t)),n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&i&&i.callback&&i.callback()}}function t(e){i("pageview",e)}try{var s={domain:r.location.hostname},n={page:t,trigger:i,trackPushState:function(){var e,i=r.history;i.pushState&&(e=i.pushState,i.pushState=function(){e.apply(this,arguments),t()}),r.addEventListener("popstate",t)},configure:function(e,i){s[e]=i}},e=r.plausible.q||[];r.plausible=function(){var e=[].slice.call(arguments),i=e.shift();n[i].apply(this,e)};for(var c=0;c<e.length;c++)r.plausible.apply(this,e[c])}catch(e){(new Image).src=a+"/api/error?message="+encodeURIComponent(e.message)}}(window,"<%= base_url %>");