-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbeacon.min.js
1 lines (1 loc) · 9.83 KB
/
beacon.min.js
1
!function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function i(t){return Object.keys(t).forEach(function(e){"number"==typeof t[e]&&(t[e]=String(t[e]))}),t}function r(t,e,n,r){var d=t.timing,f=t.memory,p="";p=window.location.origin?window.location.origin:window.location.protocol+"://"+window.location.host;var l=window.location.pathname;l&&l.length>0&&(p+=l);var v={abTestId:n?n.abTestId:"",memory:{},timings:{},resources:[],tempResources:[],redirectCount:void 0,documentWriteIntervention:!1,errorCount:0,eventType:u.EventType.Load,firstPaint:0,firstContentfulPaint:0,largestContentfulPaint:-1,firstInputDelay:-1,cumulativeLayoutShift:-1,si:n?n.si:0,startTime:t.timeOrigin||(d?d.navigationStart:0),versions:{fl:n?n.version:"",js:"2020.8.1",timings:1},pageloadId:e,location:p};if("function"==typeof t.getEntriesByType){var m=t.getEntriesByType("navigation");if(m&&Array.isArray(m)&&m.length>0){v.timingsV2={},v.versions.timings=2,delete v.timings;c(m[0],v.timingsV2)}}if(1===v.versions.timings){c(d,v.timings)}if(c(f,v.memory),v.redirectCount=t.navigation&&t.navigation.redirectCount,v.documentWriteIntervention=a(),v.firstPaint=o("first-paint"),v.firstContentfulPaint=o("first-contentful-paint"),v.errorCount=window.__cfErrCount||0,r&&(v.largestContentfulPaint=void 0!==r.lcp?r.lcp:-1,v.firstInputDelay=void 0!==r.fid?r.fid:-1,v.cumulativeLayoutShift=void 0!==r.cls?r.cls:-1),"function"==typeof t.getEntriesByType){var y=t.getEntriesByType("resource"),g=0,w=0;y.forEach(function(t){var e={n:t.name,s:s(t.startTime),d:s(t.duration),i:t.initiatorType,p:t.nextHopProtocol,rs:s(t.redirectStart),re:s(t.redirectEnd),fs:s(t.fetchStart),ds:s(t.domainLookupStart),de:s(t.domainLookupEnd),cs:s(t.connectStart),ce:s(t.connectEnd),qs:s(t.requestStart),ps:s(t.responseStart),pe:s(t.responseEnd),ws:s(t.workerStart),ss:s(t.secureConnectionStart),ts:t.transferSize,ec:t.encodedBodySize,dc:t.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" }'),e.ct=i(window.__cfBeaconCustomTag)),void 0===v.tempResources[w]&&(v.tempResources[w]=[]);var n=JSON.stringify(e).length;g+n<62e3?(g+=n,v.tempResources[w].push(e)):(w++,g=0)})}return JSON.stringify(v).length>=64e3&&(v.resources=[]),v}function o(t){if("function"==typeof performance.getEntriesByType){var e=performance.getEntriesByType("paint").filter(function(e){return e.name===t})[0];return e?e.startTime:0}return 0}function a(){var t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(!t)return!1;var e=parseInt(t[2],10),n=navigator.connection;return e>=55&&!!n&&"cellular"===n.type&&n.downlinkMax<=.115}function s(t){return null==t?void 0:Math.round(1e3*t)/1e3}function c(t,e){for(var n in t){var i=t[n];void 0===e||"number"!=typeof i&&"string"!=typeof i||(e[n]=i)}}e.__esModule=!0;var u=n(1),d=n(2),f=n(3),p=n(4);!function(){var t=window.performance||window.webkitPerformance||window.msPerformance||window.mozPerformance,e="function"==typeof document.querySelector?document.querySelector("script[data-cf-beacon]"):void 0,n=p(),i=window.__cfBeacon,o=!1,a=!1;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&!o&&a&&(o=!0,m())});var s={lcp:void 0,cls:void 0,fid:void 0},c=function(t){"CLS"===t.name?s.cls=t.value:"FID"===t.name?s.fid=t.value:"LCP"===t.name&&(s.lcp=t.value)};if(f.getLCP(c),f.getFID(c),"function"==typeof PerformanceObserver&&PerformanceObserver.supportedEntryTypes.includes("layout-shift")&&f.getCLS(c),e){var l=e.getAttribute("data-cf-beacon");if(l)try{i=JSON.parse(l)}catch(t){}}if(t&&i&&i.rayId){var v=function(){var e=r(t,n,i);if(e&&i){var o="req_id="+i.rayId,a=e.tempResources;delete e.tempResources,a.forEach(function(t,n){e.resources=t,0!=n&&(e.bypassTiming=!0),i&&(d.sendObjectBeacon(o,e),void 0!==i.forward&&void 0!==i.forward.url&&d.sendObjectBeacon(o,e,function(){},!1,i.forward.url))})}},m=function(){var e=r(t,n,i,s);e.resources=[],delete e.tempResources,e.eventType=u.EventType.Additional,i&&d.sendObjectBeacon("req_id="+i.rayId,e,function(){},!0)},y=function(){a=!0;var t=window.__cfRl&&window.__cfRl.done||window.__cfQR&&window.__cfQR.done;t?t.then(v):v()};"complete"===window.document.readyState?y():window.addEventListener("load",function(){window.setTimeout(y)})}}()},function(t,e,n){"use strict";e.__esModule=!0;!function(t){t[t.Load=1]="Load",t[t.Additional=2]="Additional"}(e.EventType||(e.EventType={}))},function(t,e,n){"use strict";function i(t,e,n,i,r){void 0===i&&(i=!1),void 0===r&&(r=null);var o=r||"/cdn-cgi/beacon/performance";o+="?"+t;var a=!0;if(navigator&&"string"==typeof navigator.userAgent)try{var s=navigator.userAgent.match(/Chrome\/([0-9]+)/);s&&s[0].toLowerCase().indexOf("chrome")>-1&&parseInt(s[1])<81&&(a=!1)}catch(t){}if(navigator&&"function"==typeof navigator.sendBeacon&&a&&i){e.st=1;var c=JSON.stringify(e),u={type:"application/json"};navigator.sendBeacon(o,new Blob([c],u))}else{e.st=2;var c=JSON.stringify(e),d=new XMLHttpRequest;n&&(d.onreadystatechange=function(){4==this.readyState&&204==this.status&&n()}),d.open("POST",o),d.setRequestHeader("content-type","application/json"),d.send(c)}}e.__esModule=!0,e.sendObjectBeacon=i},function(t,e,n){"use strict";e.__esModule=!0;var i,r,o=function(){return"".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)},a=function(t){return{name:t,value:arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,delta:0,entries:[],id:o(),isFinal:!1}},s=function(t,e){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var n=new PerformanceObserver(function(t){return t.getEntries().map(e)});return n.observe({type:t,buffered:!0}),n}}catch(t){}},c=!1,u=!1,d=function(t){c=!t.persisted},f=function(){addEventListener("pagehide",d),addEventListener("unload",function(){})},p=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];u||(f(),u=!0),addEventListener("visibilitychange",function(e){var n=e.timeStamp;"hidden"===document.visibilityState&&t({timeStamp:n,isUnloading:c})},{capture:!0,once:e})},l=function(t,e,n,i){var r;return function(){n&&e.isFinal&&n.disconnect(),e.value>=0&&(i||e.isFinal||"hidden"===document.visibilityState)&&(e.delta=e.value-(r||0),(e.delta||e.isFinal||void 0===r)&&(t(e),r=e.value))}},v=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=a("CLS",0),r=function(t){t.hadRecentInput||(i.value+=t.value,i.entries.push(t),e())},o=s("layout-shift",r);o&&(e=l(t,i,o,n),p(function(t){var n=t.isUnloading;o.takeRecords().map(r),n&&(i.isFinal=!0),e()}))},m=function(){return void 0===i&&(i="hidden"===document.visibilityState?0:1/0,p(function(t){var e=t.timeStamp;return i=e},!0)),{get timeStamp(){return i}}},y=function(t){var e,n=a("FCP"),i=m(),r=s("paint",function(t){"first-contentful-paint"===t.name&&t.startTime<i.timeStamp&&(n.value=t.startTime,n.isFinal=!0,n.entries.push(t),e())});r&&(e=l(t,n,r))},g=function(t){var e=a("FID"),n=m(),i=function(t){t.startTime<n.timeStamp&&(e.value=t.processingStart-t.startTime,e.entries.push(t),e.isFinal=!0,o())},r=s("first-input",i),o=l(t,e,r);r?p(function(){r.takeRecords().map(i),r.disconnect()},!0):window.perfMetrics&&window.perfMetrics.onFirstInputDelay&&window.perfMetrics.onFirstInputDelay(function(t,i){i.timeStamp<n.timeStamp&&(e.value=t,e.isFinal=!0,e.entries=[{entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+t}],o())})},w=function(){return r||(r=new Promise(function(t){return["scroll","keydown","pointerdown"].map(function(e){addEventListener(e,t,{once:!0,passive:!0,capture:!0})})})),r},h=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=a("LCP"),r=m(),o=function(t){var n=t.startTime;n<r.timeStamp?(i.value=n,i.entries.push(t)):i.isFinal=!0,e()},c=s("largest-contentful-paint",o);if(c){e=l(t,i,c,n);var u=function(){i.isFinal||(c.takeRecords().map(o),i.isFinal=!0,e())};w().then(u),p(u,!0)}},S=function(t){var e,n=a("TTFB");e=function(){try{var e=performance.getEntriesByType("navigation")[0]||function(){var t=performance.timing,e={entryType:"navigation",startTime:0};for(var n in t)"navigationStart"!==n&&"toJSON"!==n&&(e[n]=Math.max(t[n]-t.navigationStart,0));return e}();n.value=n.delta=e.responseStart,n.entries=[e],n.isFinal=!0,t(n)}catch(t){}},"complete"===document.readyState?setTimeout(e,0):addEventListener("pageshow",e)};e.getCLS=v,e.getFCP=y,e.getFID=g,e.getLCP=h,e.getTTFB=S},function(t,e,n){"use strict";function i(t,e,n){var i=e&&n||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null),t=t||{};var a=t.random||(t.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e)for(var s=0;s<16;++s)e[i+s]=a[s];return e||o(a)}var r=n(5),o=n(6);t.exports=i},function(t,e,n){"use strict";var i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(i){var r=new Uint8Array(16);t.exports=function(){return i(r),r}}else{var o=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}},function(t,e,n){"use strict";function i(t,e){var n=e||0,i=r;return[i[t[n++]],i[t[n++]],i[t[n++]],i[t[n++]],"-",i[t[n++]],i[t[n++]],"-",i[t[n++]],i[t[n++]],"-",i[t[n++]],i[t[n++]],"-",i[t[n++]],i[t[n++]],i[t[n++]],i[t[n++]],i[t[n++]],i[t[n++]]].join("")}for(var r=[],o=0;o<256;++o)r[o]=(o+256).toString(16).substr(1);t.exports=i}]);