mirror of
https://github.com/plausible/analytics.git
synced 2024-11-26 00:24:44 +03:00
Fix p.js
This commit is contained in:
parent
d03b31450f
commit
2be99db54d
@ -1 +1 @@
|
||||
!function(r,a){"use strict";function o(e){console.warn("[Plausible] Ignoring event because "+e)}function l(){var e,i,t=JSON.parse((e="plausible_user",(i=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)")))?decodeURIComponent(i[1]):null));return t?{initial_referrer:t.initial_referrer&&decodeURIComponent(t.initial_referrer),initial_source:t.initial_source&&decodeURIComponent(t.initial_source)}:(t={initial_referrer:r.document.referrer||null,initial_source:getSourceFromQueryParam()},function(e,i){var t=new Date;t.setTime(t.getTime()+94608e6);var n="; expires="+t.toUTCString();document.cookie=e+"="+(i||"")+n+"; samesite=strict; path=/"}("plausible_user",JSON.stringify({initial_referrer:t.initial_referrer&&encodeURIComponent(t.initial_referrer),initial_source:t.initial_source&&encodeURIComponent(t.initial_source)})),t)}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 %>");
|
||||
!function(){"use strict";var e=window.document.currentScript,r=new URL(e.src).origin;function o(e){console.warn("[Plausible] Ignoring event because "+e)}function a(){var e,i,n=JSON.parse((e="plausible_user",(i=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)")))?decodeURIComponent(i[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:window.document.referrer||null,initial_source:getSourceFromQueryParam()},function(e,i){var n=new Date;n.setTime(n.getTime()+94608e6);var t="; expires="+n.toUTCString();document.cookie=e+"="+(i||"")+t+"; samesite=strict; path=/"}("plausible_user",JSON.stringify({initial_referrer:n.initial_referrer&&encodeURIComponent(n.initial_referrer),initial_source:n.initial_source&&encodeURIComponent(n.initial_source)})),n)}function i(e,i){if(/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(window.location.hostname))return o("website is running locally");if("file:"===window.location.protocol)return o("website is running locally");if("prerender"===window.document.visibilityState)return o("document is prerendering");var n=c.trackAcquisition?a():{};n.n=e,n.u=window.location.href,n.d=c.domain,n.r=window.document.referrer||null,n.w=window.innerWidth;var t=new XMLHttpRequest;t.open("POST",r+"/api/event",!0),t.setRequestHeader("Content-Type","text/plain"),t.send(JSON.stringify(n)),t.onreadystatechange=function(){t.readyState==XMLHttpRequest.DONE&&i&&i.callback&&i.callback()}}function n(e){i("pageview",e)}try{var c={domain:window.location.hostname},t={page:n,trigger:i,trackPushState:function(){var e,i=window.history;i.pushState&&(e=i.pushState,i.pushState=function(){e.apply(this,arguments),n()}),window.addEventListener("popstate",n)},configure:function(e,i){c[e]=i}},s=window.plausible.q||[];window.plausible=function(){var e=[].slice.call(arguments),i=e.shift();t[i].apply(this,e)};for(var l=0;l<s.length;l++)window.plausible.apply(this,s[l])}catch(e){(new Image).src=r+"/api/error?message="+encodeURIComponent(e.message)}}();
|
@ -5,6 +5,7 @@
|
||||
(function(){
|
||||
'use strict';
|
||||
|
||||
var scriptEl = window.document.currentScript;
|
||||
var plausibleHost = new URL(scriptEl.src).origin
|
||||
|
||||
function setCookie(name,value) {
|
||||
|
Loading…
Reference in New Issue
Block a user