-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeacon.min.js
1 lines (1 loc) · 12.9 KB
/
beacon.min.js
1
!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e){var t="";if(t=window.location.origin?window.location.origin:window.location.protocol+"://"+window.location.host,e)if(String.prototype.startsWith||(String.prototype.startsWith=function(e,t){return this.substr(t||0,e.length)===e}),e.startsWith("/"))t+=e;else try{var n=new URL(e);return n.protocol+"://"+n.host+n.pathname}catch(e){}else{var r=window.location.pathname;r&&r.length>0&&(t+=r)}return t}function i(e){return Object.keys(e).forEach(function(t){"number"==typeof e[t]&&(e[t]=String(e[t]))}),e}function o(e){if("function"==typeof performance.getEntriesByType){var t=performance.getEntriesByType("paint").filter(function(t){return t.name===e})[0];return t?t.startTime:0}return 0}function a(){var e=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(!e)return!1;var t=parseInt(e[2],10),n=navigator.connection;return t>=55&&!!n&&"cellular"===n.type&&n.downlinkMax<=.115}function c(e){return null==e?void 0:Math.round(1e3*e)/1e3}function s(e,t){for(var n in e){var r=e[n];void 0===t||"number"!=typeof r&&"string"!=typeof r||(t[n]=r)}}t.__esModule=!0;var u=n(1),f=n(2),d=n(3),l=n(4);!function(){function e(){var e=v.timing,t="";try{t="function"==typeof v.getEntriesByType?new URL(v.getEntriesByType("navigation")[0].name).pathname:p?new URL(p).pathname:window.location.pathname}catch(e){}var n={referrer:document.referrer||"",eventType:u.EventType.WebVitalsV2,lcp:{value:-1,path:void 0},cls:{value:-1,path:void 0},fid:{value:-1,path:void 0},si:h?h.si:0,versions:{js:"2021.4.0"},pageloadId:y,location:r(),landingPath:t,startTime:v.timeOrigin||(e?e.navigationStart:0)};return T&&(n.lcp=T.lcp&&void 0!==T.lcp.value?T.lcp:n.lcp,n.fid=T.fid&&void 0!==T.fid.value?T.fid:n.fid,n.cls=T.cls&&void 0!==T.cls.value?T.cls:n.cls),R&&h&&(n.siteToken=h.token),n}function t(e,t){void 0===t&&(t=u.EventType.Load);var f=v.timing,d=v.memory,l=e||r(),p=document.referrer||"",m=g[2]||g[1]||g[0],w={abTestId:h?h.abTestId:"",memory:{},timings:{},resources:[],tempResources:[],referrer:R&&O&&S&&m?m.url:p,documentWriteIntervention:!1,errorCount:0,eventType:t,firstPaint:0,firstContentfulPaint:0,largestContentfulPaint:-1,firstInputDelay:-1,cumulativeLayoutShift:-1,si:h?h.si:0,startTime:v.timeOrigin||(f?f.navigationStart:0),versions:{fl:h?h.version:"",js:"2021.4.0",timings:1},pageloadId:y,location:l};if(void 0==n){if("function"==typeof v.getEntriesByType){var b=v.getEntriesByType("navigation");b&&Array.isArray(b)&&b.length>0&&(w.timingsV2={},w.versions.timings=2,delete w.timings,s(b[0],w.timingsV2))}1===w.versions.timings&&s(f,w.timings),s(d,w.memory)}if(w.documentWriteIntervention=a(),w.firstPaint=o("first-paint"),w.firstContentfulPaint=o("first-contentful-paint"),w.errorCount=window.__cfErrCount||0,T&&(w.largestContentfulPaint=T.lcp&&void 0!==T.lcp.value?T.lcp.value:-1,w.firstInputDelay=T.fid&&void 0!==T.fid.value?T.fid.value:-1,w.cumulativeLayoutShift=T.cls&&void 0!==T.cls.value?T.cls.value:-1),R&&h&&(w.siteToken=h.token,S=!0),"function"==typeof v.getEntriesByType){var E=v.getEntriesByType("resource"),L=0,_=0;E.forEach(function(e){var t={n:e.name,s:c(e.startTime),d:c(e.duration),i:e.initiatorType,p:e.nextHopProtocol,rs:c(e.redirectStart),re:c(e.redirectEnd),fs:c(e.fetchStart),ds:c(e.domainLookupStart),de:c(e.domainLookupEnd),cs:c(e.connectStart),ce:c(e.connectEnd),qs:c(e.requestStart),ps:c(e.responseStart),pe:c(e.responseEnd),ws:c(e.workerStart),ss:c(e.secureConnectionStart),ts:e.transferSize,ec:e.encodedBodySize,dc:e.decodedBodySize};window.__cfBeaconCustomTag&&(("object"!=typeof window.__cfBeaconCustomTag||Array.isArray(window.__cfBeaconCustomTag))&&console.warn('Invalid custom tag format. Please use the following format: { "first_key": "first_value", "second_key": "second_value" }'),t.ct=i(window.__cfBeaconCustomTag)),w.tempResources&&void 0===w.tempResources[_]&&(w.tempResources[_]=[]);var n=JSON.stringify(t).length;L+n<62e3&&w.tempResources?(L+=n,w.tempResources[_].push(t)):(_++,L=0)})}return JSON.stringify(w).length>=64e3&&(w.resources=[]),R&&1===w.eventType&&(void 0!==n&&(delete w.timings,delete w.memory,delete w.errorCount,delete w.documentWriteIntervention),delete w.firstPaint,delete w.firstContentfulPaint,delete w.largestContentfulPaint,delete w.firstInputDelay,delete w.cumulativeLayoutShift),w}var n,p,v=window.performance||window.webkitPerformance||window.msPerformance||window.mozPerformance,m=document.currentScript||("function"==typeof document.querySelector?document.querySelector("script[data-cf-beacon]"):void 0),y=l(),g=[],h=window.__cfBeacon,w=!1,S=!1;document.addEventListener("visibilitychange",function(){R&&O&&0===g.filter(function(e){return e.id===y}).length&&I(),"hidden"===document.visibilityState&&!w&&S&&(w=!0,k(O&&R))});var T={lcp:void 0,cls:void 0,fid:void 0},b=function(e){var t=window.location.pathname;"CLS"===e.name?T.cls={value:e.value,path:t}:"FID"===e.name?T.fid={value:e.value,path:t}:"LCP"===e.name&&(T.lcp={value:e.value,path:t})};if("function"==typeof PerformanceObserver&&(d.getLCP(b,!0),d.getFID(b),PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes("layout-shift")&&d.getCLS(b,!0)),m){var E=m.getAttribute("data-cf-beacon");if(E)try{h=JSON.parse(E)}catch(e){}else{var L=m.getAttribute("src");if(L&&"function"==typeof URLSearchParams){h={};var _=new URLSearchParams(L.replace(/^[^\?]+\??/,"")),C=_.get("token");C&&(h.token=C);var P=_.get("spa");h.spa=null===P||"true"===P}}}var R=!(!h||!h.token),O=h&&(void 0===h.spa||!0===h.spa);if(v&&h&&(h.rayId||h.token)){var B=R?h.send&&h.send.to?h.send.to:"https://cloudflareinsights.com/cdn-cgi/rum":null,I=function(e){var n=function(e,t,n){r.resources=e,0!=t&&(r.bypassTiming=!0),h&&(1===h.r&&(r.resources=[]),R&&O&&0===t&&(g.push({id:r.pageloadId,url:r.location}),g.length>3&&g.shift()),f.sendObjectBeacon(n,r,function(){},!1,B),void 0!==h.forward&&void 0!==h.forward.url&&f.sendObjectBeacon(n,r,function(){},!1,h.forward.url))},r=t(e);if(r&&h){var i="req_id="+h.rayId,o=r.tempResources;if(delete r.tempResources,R&&O&&o&&0===o.length&&n([],0,i),!o)return;o.forEach(function(e,t){n(e,t,i)})}},k=function(n){var r=n?e():t(void 0,u.EventType.Additional);n||(r.resources=[],delete r.tempResources),h&&f.sendObjectBeacon("req_id="+h.rayId,r,function(){},!0,B)},A=function(){S=!0;var e=window.__cfRl&&window.__cfRl.done||window.__cfQR&&window.__cfQR.done;e?e.then(I):I()};"complete"===window.document.readyState?A():window.addEventListener("load",function(){window.setTimeout(A)}),O&&R&&(p=r(),function(e){var t=e.pushState;if(t){var i=function(){y=l(),"function"==typeof v.clearResourceTimings&&v.clearResourceTimings()};e.pushState=function(o,a,c){return n=r(c),0===g.filter(function(e){return e.id===y}).length&&I(r()),i(),t.apply(e,[o,a,c])},window.addEventListener("popstate",function(e){0===g.filter(function(e){return e.id===y}).length&&I(n),n=r(),i()})}}(window.history))}}()},function(e,t,n){"use strict";t.__esModule=!0;!function(e){e[e.Load=1]="Load",e[e.Additional=2]="Additional",e[e.WebVitalsV2=3]="WebVitalsV2"}(t.EventType||(t.EventType={}))},function(e,t,n){"use strict";function r(e,t,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=null);var o=i||"/cdn-cgi/beacon/performance?"+e,a=!0;if(navigator&&"string"==typeof navigator.userAgent)try{var c=navigator.userAgent.match(/Chrome\/([0-9]+)/);c&&c[0].toLowerCase().indexOf("chrome")>-1&&parseInt(c[1])<81&&(a=!1)}catch(e){}if(navigator&&"function"==typeof navigator.sendBeacon&&a&&r){t.st=1;var s=JSON.stringify(t),u={type:"application/json"};navigator.sendBeacon(o,new Blob([s],u))}else{t.st=2;var s=JSON.stringify(t),f=new XMLHttpRequest;n&&(f.onreadystatechange=function(){4==this.readyState&&204==this.status&&n()}),f.open("POST",o,!0),f.setRequestHeader("content-type","application/json"),f.send(s)}}t.__esModule=!0,t.sendObjectBeacon=r},function(e,t,n){"use strict";t.__esModule=!0;var r,i,o,a,c=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v1-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},s=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var n=new PerformanceObserver(function(e){return e.getEntries().map(t)});return n.observe({type:e,buffered:!0}),n}}catch(e){}},u=!1,f=function(e,t){u||"undefined"!=typeof InstallTrigger||(addEventListener("beforeunload",function(){}),u=!0),addEventListener("visibilitychange",function n(r){"hidden"===document.visibilityState&&(e(r),t&&removeEventListener("visibilitychange",n,!0))},!0)},d=function(e){addEventListener("pageshow",function(t){t.persisted&&e(t)},!0)},l="function"==typeof WeakSet?new WeakSet:new Set,p=function(e,t,n){var r;return function(){t.value>=0&&(n||l.has(t)||"hidden"===document.visibilityState)&&(t.delta=t.value-(r||0),(t.delta||void 0===r)&&(r=t.value,e(t)))}},v=function(e,t){var n,r=c("CLS",0),i=function(e){e.hadRecentInput||(r.value+=e.value,r.entries.push(e),n())},o=s("layout-shift",i);o&&(n=p(e,r,t),f(function(){o.takeRecords().map(i),n()}),d(function(){r=c("CLS",0),n=p(e,r,t)}))},m=-1,y=function(){return"hidden"===document.visibilityState?0:1/0},g=function(){f(function(e){var t=e.timeStamp;m=t},!0)},h=function(){return m<0&&(m=y(),g(),d(function(){setTimeout(function(){m=y(),g()},0)})),{get timeStamp(){return m}}},w=function(e,t){var n,r=h(),i=c("FCP"),o=s("paint",function(e){"first-contentful-paint"===e.name&&(o&&o.disconnect(),e.startTime<r.timeStamp&&(i.value=e.startTime,i.entries.push(e),l.add(i),n()))});o&&(n=p(e,i,t),d(function(r){i=c("FCP"),n=p(e,i,t),requestAnimationFrame(function(){requestAnimationFrame(function(){i.value=performance.now()-r.timeStamp,l.add(i),n()})})}))},S={passive:!0,capture:!0},T=new Date,b=function(e,t){r||(r=t,i=e,o=new Date,_(removeEventListener),E())},E=function(){if(i>=0&&i<o-T){var e={entryType:"first-input",name:r.type,target:r.target,cancelable:r.cancelable,startTime:r.timeStamp,processingStart:r.timeStamp+i};a.forEach(function(t){t(e)}),a=[]}},L=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){b(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,S),removeEventListener("pointercancel",r,S)};addEventListener("pointerup",n,S),addEventListener("pointercancel",r,S)}(t,e):b(t,e)}},_=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,L,S)})},C=function(e,t){var n,o=h(),u=c("FID"),v=function(e){e.startTime<o.timeStamp&&(u.value=e.processingStart-e.startTime,u.entries.push(e),l.add(u),n())},m=s("first-input",v);n=p(e,u,t),m&&f(function(){m.takeRecords().map(v),m.disconnect()},!0),m&&d(function(){var o;u=c("FID"),n=p(e,u,t),a=[],i=-1,r=null,_(addEventListener),o=v,a.push(o),E()})},P=function(e,t){var n,r=h(),i=c("LCP"),o=function(e){var t=e.startTime;t<r.timeStamp&&(i.value=t,i.entries.push(e)),n()},a=s("largest-contentful-paint",o);if(a){n=p(e,i,t);var u=function(){l.has(i)||(a.takeRecords().map(o),a.disconnect(),l.add(i),n())};["keydown","click"].forEach(function(e){addEventListener(e,u,{once:!0,capture:!0})}),f(u,!0),d(function(r){i=c("LCP"),n=p(e,i,t),requestAnimationFrame(function(){requestAnimationFrame(function(){i.value=performance.now()-r.timeStamp,l.add(i),n()})})})}},R=function(e){var t,n=c("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();n.value=n.delta=t.responseStart,n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("pageshow",t)};t.getCLS=v,t.getFCP=w,t.getFID=C,t.getLCP=P,t.getTTFB=R},function(e,t,n){"use strict";function r(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null),e=e||{};var a=e.random||(e.rng||i)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var c=0;c<16;++c)t[r+c]=a[c];return t||o(a)}var i=n(5),o=n(6);e.exports=r},function(e,t,n){"use strict";var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var i=new Uint8Array(16);e.exports=function(){return r(i),i}}else{var o=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}},function(e,t,n){"use strict";function r(e,t){var n=t||0,r=i;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}for(var i=[],o=0;o<256;++o)i[o]=(o+256).toString(16).substr(1);e.exports=r}]);