perfops-rom
Advanced tools
Comparing version 1.1.18 to 1.1.19
219
dist/rom.js
"use strict"; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
(function (Promise) { | ||
@@ -20,4 +8,2 @@ var API_URL = 'https://devnull.perfops.net'; | ||
var STORE_DATA_INTERVAL = 1000; // How often we should try to send data to the rum-parser | ||
var QUEUE_LIMIT = 2; // Defaults for repeats. Those could be overridden by settings from rum-cdn | ||
@@ -80,4 +66,4 @@ | ||
function fetchJs(url, cb) { | ||
var script = document.createElement('script'), | ||
loaded; | ||
var script = document.createElement('script'); | ||
var loaded = false; | ||
@@ -139,2 +125,3 @@ script.onreadystatechange = script.onload = function () { | ||
id: resource.id, | ||
domain: domain, | ||
up: 0 | ||
@@ -172,34 +159,26 @@ }; | ||
"data": [{ | ||
"id": 30, | ||
"cdnUrl": "https://perfops.doracdn.com/500b-db-bench.jpg", | ||
"id": 17, | ||
"cdnUrl": "https://edgecast-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 38, | ||
"cdnUrl": "https://perf.psychz.net/500b-bench.jpg", | ||
"id": 36, | ||
"cdnUrl": "https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 2, | ||
"cdnUrl": "https://ovh-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 24, | ||
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg", | ||
"id": 22, | ||
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 17, | ||
"cdnUrl": "https://edgecast-cdn.perfops.io/500b-bench.jpg", | ||
"id": 15, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 22, | ||
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg", | ||
"p": 0 | ||
"id": 14, | ||
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 13, | ||
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg", | ||
"id": 30, | ||
"cdnUrl": "https://perfops.doracdn.com/500b-db-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 39, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 7, | ||
@@ -217,38 +196,38 @@ "cdnUrl": "https://google-cdn.perfops.io/500b-google-bench.jpg", | ||
}, { | ||
"id": 11, | ||
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg", | ||
"id": 2, | ||
"cdnUrl": "https://ovh-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 20, | ||
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg", | ||
"id": 9, | ||
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 15, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"id": 3, | ||
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 18, | ||
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg", | ||
"id": 13, | ||
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 9, | ||
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg", | ||
"id": 38, | ||
"cdnUrl": "https://perf.psychz.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 1, | ||
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 14, | ||
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg", | ||
"id": 4, | ||
"cdnUrl": "https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 36, | ||
"cdnUrl": "https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg", | ||
"id": 39, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 10, | ||
"cdnUrl": "https://akamai-perfops2.azureedge.net/500b-bench.jpg", | ||
"id": 11, | ||
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 3, | ||
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 5, | ||
@@ -258,6 +237,10 @@ "cdnUrl": "https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg", | ||
}, { | ||
"id": 4, | ||
"cdnUrl": "https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg", | ||
"id": 18, | ||
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 20, | ||
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 6, | ||
@@ -267,5 +250,5 @@ "cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg", | ||
}, { | ||
"id": 1, | ||
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg", | ||
"p": 1 | ||
"id": 24, | ||
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
@@ -275,15 +258,13 @@ "id": 12, | ||
"p": 1 | ||
}] | ||
}, { | ||
"id": 10, | ||
"cdnUrl": "https://akamai-perfops2.azureedge.net/500b-bench.jpg", | ||
"p": 1 | ||
}], | ||
"config": { | ||
"repeats": "30", | ||
"interval": "10" | ||
} | ||
}; | ||
}); | ||
} // eslint-disable-next-line no-unused-vars | ||
function fetchResourceListTest() { | ||
return Promise.resolve({ | ||
data: [{ | ||
id: 1, | ||
cdnUrl: 'http://localhost:9999' | ||
}] | ||
}); | ||
} | ||
@@ -324,60 +305,11 @@ | ||
function run() { | ||
var results = []; | ||
var metadata = { | ||
ua: navigator.userAgent, | ||
hostname: window.location.hostname, | ||
client: clientKey | ||
}; | ||
var storeInterval; | ||
var finished = false; | ||
var store = function store() { | ||
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
logInfo("Try to store ".concat(results.length, " items")); | ||
if (finished && results.length === 0) { | ||
logInfo('Store data interval cleared'); | ||
clearInterval(storeInterval); | ||
} | ||
if (results.length < 1) { | ||
logInfo('Batch is empty'); | ||
return; | ||
} | ||
if (results.length < 3 && !force) { | ||
logInfo('Batch is to small. Wait for more results'); | ||
return; | ||
} | ||
var slow = results.reduce(function (ac, val) { | ||
return ac + (val.time > 2000 ? 1 : 0); | ||
}, 0); // All the measurements in a batch are slow. Probably something with a user's internet connection. Skip the batch. | ||
if (slow === results.length) { | ||
logInfo("Skip batch of a ".concat(slow, " slow probes")); | ||
results.splice(0, slow); | ||
return; | ||
} | ||
storeResults(metadata, results.splice(0, results.length)).then(function () { | ||
return logInfo("Results stored"); | ||
}).catch(function (data) { | ||
var _results; | ||
return (_results = results).push.apply(_results, _toConsumableArray(data)); | ||
}); | ||
}; | ||
var numberOfRepeat = 0; | ||
var processor = function processor() { | ||
finished = false; // Clean up before new run. | ||
clearInterval(storeInterval); // Clear previous interval | ||
results = []; // Remove outdated probe results if they aren't stored till now. | ||
storeInterval = setInterval(store, STORE_DATA_INTERVAL); // Set new interval for data storing | ||
var metadata = { | ||
ua: navigator.userAgent, | ||
hostname: window.location.hostname, | ||
client: clientKey | ||
}; | ||
var results = []; | ||
fetchResourceList().then(function (response) { | ||
@@ -391,3 +323,5 @@ var chunkedData = function (array, n) { | ||
return pMapSeries(chunkedData, function (resources) { | ||
var tooSlow = 0; | ||
var down = 0; | ||
performance.clearResourceTimings(); | ||
return Promise.all(resources.map(function (resource) { | ||
@@ -397,2 +331,4 @@ return fetchResource(resource).then(function (data) { | ||
down++; | ||
} else if (data.time > 2000) { | ||
tooSlow++; | ||
} // time must be between 3 and 3000 ms | ||
@@ -406,3 +342,14 @@ // if 2 or more providers in one batch fail, drop all results | ||
results.push(data); | ||
if (results.push(data) >= QUEUE_LIMIT) { | ||
down = 0; | ||
if (tooSlow < QUEUE_LIMIT) { | ||
tooSlow = 0; | ||
} else { | ||
tooSlow = 0; | ||
return results.splice(0, results.length); | ||
} | ||
return storeResults(metadata, results.splice(0, results.length)); | ||
} | ||
}); | ||
@@ -412,6 +359,5 @@ })); | ||
}).then(logInfo, logError).then(function () { | ||
finished = true; | ||
numberOfRepeat += 1; | ||
store(true); | ||
}).then(function () { | ||
storeResults(metadata, results.splice(0, results.length)); | ||
if (numberOfRepeat < REPEAT_COUNT) { | ||
@@ -421,4 +367,4 @@ setTimeout(processor, REPEAT_DELAY); | ||
}); | ||
}; // eslint-disable-next-line comma-dangle | ||
// prettier-ignore | ||
}; // prettier-ignore | ||
// eslint-disable-next-line comma-dangle | ||
@@ -436,6 +382,3 @@ | ||
method: 'POST' | ||
}).catch(function (err) { | ||
logError(err); | ||
throw data; | ||
}); | ||
}).catch(logError); | ||
} | ||
@@ -442,0 +385,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(d){var e,a="https://devnull.perfops.net",s="https://rum-cdn.perfops.net/providers",p=3e5,u=6e4,l=3,n=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},f=n.logInfo,h=n.logError,g=window.rum?window.rum.key:void 0;function m(e){return Math.max(0,Number(e.toFixed(2)))}function b(r,e){var n=1<arguments.length&&void 0!==e?e:{},t=n.cb,o=void 0===t?function(){}:t,c=n.data,i=n.method,a=void 0===i?"GET":i,s=n.timeout,p=void 0===s?3e3:s;return new d(function(e,n){var t=new XMLHttpRequest;t.onload=function(){return e(t)},t.onerror=t.ontimeout=function(){h(t),n(new Error("Status ".concat(t.status,". Response: ").concat(t.statusText)))},t.open(a,r),t.timeout=p,o(t),t.send(c)})}function y(e){u=e.interval?1e3*parseInt(e.interval):u,e.repeats&&(l="Infinite"===e.repeats?Math.pow(2,32):parseInt(e.repeats))}function t(){function n(e){var n=0<arguments.length&&void 0!==e&&e;if(f("Try to store ".concat(o.length," items")),i&&0===o.length&&(f("Store data interval cleared"),clearInterval(r)),o.length<1)f("Batch is empty");else if(o.length<3&&!n)f("Batch is to small. Wait for more results");else{var t=o.reduce(function(e,n){return e+(2e3<n.time?1:0)},0);if(t===o.length)return f("Skip batch of a ".concat(t," slow probes")),void o.splice(0,t);(function(e,n){return b("".concat(a,"/rum/v1"),{data:JSON.stringify({metadata:e,data:n}),method:"POST"}).catch(function(e){throw h(e),n})})(c,o.splice(0,o.length)).then(function(){return f("Results stored")}).catch(function(e){var n;return(n=o).push.apply(n,_toConsumableArray(e))})}}var r,o=[],c={ua:navigator.userAgent,hostname:window.location.hostname,client:g},i=!1,t=0;setTimeout(function e(){i=!1,clearInterval(r),o=[],r=setInterval(n,1e3),function(){var n="perfops-rum-resources",e=JSON.parse(window.localStorage.getItem(n));return e&&e.expiry>Date.now()?(e.config&&y(e.config),d.resolve(e.data)):b(s).then(function(e){return JSON.parse(e.response)}).then(function(e){if(!e||!e.data||!e.data.length)throw new Error("Empty response.data");return window.localStorage.setItem(n,JSON.stringify({data:e.data,config:e.config,expiry:Date.now()+p})),e.config&&y(e.config),e.data}).catch(function(){return{data:[{id:30,cdnUrl:"https://perfops.doracdn.com/500b-db-bench.jpg",p:1},{id:38,cdnUrl:"https://perf.psychz.net/500b-bench.jpg",p:0},{id:2,cdnUrl:"https://ovh-cdn.perfops.io/500b-bench.jpg",p:1},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:0},{id:17,cdnUrl:"https://edgecast-cdn.perfops.io/500b-bench.jpg",p:1},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:0},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:1},{id:39,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:0},{id:7,cdnUrl:"https://google-cdn.perfops.io/500b-google-bench.jpg",p:1},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:1},{id:35,cdnUrl:"https://cdn81795137.blazingcdn.net/500b-blz-bench.jpg",p:1},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:1},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:1},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:1},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:1},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:1},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:1},{id:36,cdnUrl:"https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg",p:0},{id:10,cdnUrl:"https://akamai-perfops2.azureedge.net/500b-bench.jpg",p:1},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:1},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:1},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg",p:1},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:1},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:1},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:1}]}})}().then(function(e){var t;return function(e,r){return e.reduce(function(e,t){return e.then(function(n){return r(t).then(function(e){return n.push(e),n})})},d.resolve([]))}((t=e,Array.from(Array(Math.ceil(t.length/2)),function(e,n){return t.slice(2*n,2*n+2)})),function(e){var n=0;return d.all(e.map(function(e){return function(i){var a="".concat(i.cdnUrl,"?t=").concat(Date.now()),s=new URL(a).hostname;return b(a).then(function(e){var n=performance.getEntriesByName(a)[0],t={id:i.id,domain:s},r=m(n.domainLookupEnd-n.domainLookupStart),o=m(n.connectEnd-n.connectStart),c=0<o?m(n.connectEnd-n.secureConnectionStart):0;return 200<=e.status&&e.status<300&&(t=Object.assign({},t,{up:1,time:Number((n.responseEnd-n.requestStart).toFixed(2)),dnsLookupTime:r,tcpTime:o,sslTime:c,headers:e.getAllResponseHeaders()})),300<=e.status&&e.status<=500&&(t=Object.assign({},t,{up:0,dnsLookupTime:r,tcpTime:o,sslTime:c,headers:e.getAllResponseHeaders()})),t}).catch(function(){return{id:i.id,up:0}})}(e).then(function(e){e.up||n++,1<n||e.up&&(e.time<3||3e3<e.time)||o.push(e)})}))})}).then(f,h).then(function(){t+=1,n(i=!0)}).then(function(){t<l&&setTimeout(e,u)})},1e3)}e=function(){var e=["bot","headless","google","baidu","bing","msn","duckduckbot","teoma","slurp","yandex","phantomjs","pingdom","ahrefsbot"].join("|");if(new RegExp(e,"i").test(window.navigator.userAgent))console.warn("PerfOps RUM not launching due to suspicious userAgent:",window.navigator.userAgent);else if(void 0!==window.performance){if(performance.onresourcetimingbufferfull=function(){f("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof d)return t();!function(e,n){var t,r=document.createElement("script");r.onreadystatechange=r.onload=function(){t||n(),t=!0},r.setAttribute("src",e),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){d=window.ES6Promise,t()})}},"complete"===document.readyState?e():window.addEventListener("load",e)}(window.Promise); | ||
"use strict";!function(a){var n,t="https://devnull.perfops.net",c="https://rum-cdn.perfops.net/providers",i=3e5,p=6e4,s=3,e=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},d=e.logInfo,u=e.logError,h=window.rum?window.rum.key:void 0;function l(n){return Math.max(0,Number(n.toFixed(2)))}function f(r,n){var e=1<arguments.length&&void 0!==n?n:{},t=e.cb,o=void 0===t?function(){}:t,c=e.data,i=e.method,p=void 0===i?"GET":i,s=e.timeout,d=void 0===s?3e3:s;return new a(function(n,e){var t=new XMLHttpRequest;t.onload=function(){return n(t)},t.onerror=t.ontimeout=function(){u(t),e(new Error("Status ".concat(t.status,". Response: ").concat(t.statusText)))},t.open(p,r),t.timeout=d,o(t),t.send(c)})}function g(n){p=n.interval?1e3*parseInt(n.interval):p,n.repeats&&(s="Infinite"===n.repeats?Math.pow(2,32):parseInt(n.repeats))}function r(){var e=0;setTimeout(function n(){var r={ua:navigator.userAgent,hostname:window.location.hostname,client:h},o=[];(function(){var e="perfops-rum-resources",n=JSON.parse(window.localStorage.getItem(e));return n&&n.expiry>Date.now()?(n.config&&g(n.config),a.resolve(n.data)):f(c).then(function(n){return JSON.parse(n.response)}).then(function(n){if(!n||!n.data||!n.data.length)throw new Error("Empty response.data");return window.localStorage.setItem(e,JSON.stringify({data:n.data,config:n.config,expiry:Date.now()+i})),n.config&&g(n.config),n.data}).catch(function(){return{data:[{id:17,cdnUrl:"https://edgecast-cdn.perfops.io/500b-bench.jpg",p:1},{id:36,cdnUrl:"https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg",p:0},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:0},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:1},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:1},{id:30,cdnUrl:"https://perfops.doracdn.com/500b-db-bench.jpg",p:1},{id:7,cdnUrl:"https://google-cdn.perfops.io/500b-google-bench.jpg",p:1},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:1},{id:35,cdnUrl:"https://cdn81795137.blazingcdn.net/500b-blz-bench.jpg",p:1},{id:2,cdnUrl:"https://ovh-cdn.perfops.io/500b-bench.jpg",p:1},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:1},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:1},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:1},{id:38,cdnUrl:"https://perf.psychz.net/500b-bench.jpg",p:0},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:1},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg",p:1},{id:39,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:0},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:1},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:1},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:1},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:1},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:1},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:0},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:1},{id:10,cdnUrl:"https://akamai-perfops2.azureedge.net/500b-bench.jpg",p:1}],config:{repeats:"30",interval:"10"}}})})().then(function(n){var t;return function(n,r){return n.reduce(function(n,t){return n.then(function(e){return r(t).then(function(n){return e.push(n),e})})},a.resolve([]))}((t=n,Array.from(Array(Math.ceil(t.length/2)),function(n,e){return t.slice(2*e,2*e+2)})),function(n){var e=0,t=0;return performance.clearResourceTimings(),a.all(n.map(function(n){return function(i){var p="".concat(i.cdnUrl,"?t=").concat(Date.now()),s=new URL(p).hostname;return f(p).then(function(n){var e=performance.getEntriesByName(p)[0],t={id:i.id,domain:s},r=l(e.domainLookupEnd-e.domainLookupStart),o=l(e.connectEnd-e.connectStart),c=0<o?l(e.connectEnd-e.secureConnectionStart):0;return 200<=n.status&&n.status<300&&(t=Object.assign({},t,{up:1,time:Number((e.responseEnd-e.requestStart).toFixed(2)),dnsLookupTime:r,tcpTime:o,sslTime:c,headers:n.getAllResponseHeaders()})),300<=n.status&&n.status<=500&&(t=Object.assign({},t,{up:0,dnsLookupTime:r,tcpTime:o,sslTime:c,headers:n.getAllResponseHeaders()})),t}).catch(function(){return{id:i.id,domain:s,up:0}})}(n).then(function(n){if(n.up?2e3<n.time&&e++:t++,!(1<t||n.up&&(n.time<3||3e3<n.time)))return 2<=o.push(n)?(t=0,e<2?(e=0,m(r,o.splice(0,o.length))):(e=0,o.splice(0,o.length))):void 0})}))})}).then(d,u).then(function(){e+=1,m(r,o.splice(0,o.length)),e<s&&setTimeout(n,p)})},1e3)}function m(n,e){return f("".concat(t,"/rum/v1"),{data:JSON.stringify({metadata:n,data:e}),method:"POST"}).catch(u)}n=function(){var n=["bot","headless","google","baidu","bing","msn","duckduckbot","teoma","slurp","yandex","phantomjs","pingdom","ahrefsbot"].join("|");if(new RegExp(n,"i").test(window.navigator.userAgent))console.warn("PerfOps RUM not launching due to suspicious userAgent:",window.navigator.userAgent);else if(void 0!==window.performance){if(performance.onresourcetimingbufferfull=function(){d("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof a)return r();!function(n,e){var t=document.createElement("script"),r=!1;t.onreadystatechange=t.onload=function(){r||e(),r=!0},t.setAttribute("src",n),document.body.appendChild(t)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){a=window.ES6Promise,r()})}},"complete"===document.readyState?n():window.addEventListener("load",n)}(window.Promise); |
219
dist/rom3.js
"use strict"; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
(function (Promise) { | ||
@@ -20,4 +8,2 @@ var API_URL = 'https://devnull.perfops.net'; | ||
var STORE_DATA_INTERVAL = 1000; // How often we should try to send data to the rum-parser | ||
var QUEUE_LIMIT = 2; // Defaults for repeats. Those could be overridden by settings from rum-cdn | ||
@@ -80,4 +66,4 @@ | ||
function fetchJs(url, cb) { | ||
var script = document.createElement('script'), | ||
loaded; | ||
var script = document.createElement('script'); | ||
var loaded = false; | ||
@@ -139,2 +125,3 @@ script.onreadystatechange = script.onload = function () { | ||
id: resource.id, | ||
domain: domain, | ||
up: 0 | ||
@@ -172,34 +159,26 @@ }; | ||
"data": [{ | ||
"id": 30, | ||
"cdnUrl": "https://perfops.doracdn.com/500b-db-bench.jpg", | ||
"id": 17, | ||
"cdnUrl": "https://edgecast-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 38, | ||
"cdnUrl": "https://perf.psychz.net/500b-bench.jpg", | ||
"id": 36, | ||
"cdnUrl": "https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 2, | ||
"cdnUrl": "https://ovh-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 24, | ||
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg", | ||
"id": 22, | ||
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 17, | ||
"cdnUrl": "https://edgecast-cdn.perfops.io/500b-bench.jpg", | ||
"id": 15, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 22, | ||
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg", | ||
"p": 0 | ||
"id": 14, | ||
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 13, | ||
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg", | ||
"id": 30, | ||
"cdnUrl": "https://perfops.doracdn.com/500b-db-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 39, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 7, | ||
@@ -217,38 +196,38 @@ "cdnUrl": "https://google-cdn.perfops.io/500b-google-bench.jpg", | ||
}, { | ||
"id": 11, | ||
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg", | ||
"id": 2, | ||
"cdnUrl": "https://ovh-cdn.perfops.io/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 20, | ||
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg", | ||
"id": 9, | ||
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 15, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"id": 3, | ||
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 18, | ||
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg", | ||
"id": 13, | ||
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 9, | ||
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg", | ||
"id": 38, | ||
"cdnUrl": "https://perf.psychz.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 1, | ||
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 14, | ||
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg", | ||
"id": 4, | ||
"cdnUrl": "https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 36, | ||
"cdnUrl": "https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg", | ||
"id": 39, | ||
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
"id": 10, | ||
"cdnUrl": "https://akamai-perfops2.azureedge.net/500b-bench.jpg", | ||
"id": 11, | ||
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 3, | ||
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 5, | ||
@@ -258,6 +237,10 @@ "cdnUrl": "https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg", | ||
}, { | ||
"id": 4, | ||
"cdnUrl": "https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg", | ||
"id": 18, | ||
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 20, | ||
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg", | ||
"p": 1 | ||
}, { | ||
"id": 6, | ||
@@ -267,5 +250,5 @@ "cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg", | ||
}, { | ||
"id": 1, | ||
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg", | ||
"p": 1 | ||
"id": 24, | ||
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg", | ||
"p": 0 | ||
}, { | ||
@@ -275,15 +258,13 @@ "id": 12, | ||
"p": 1 | ||
}] | ||
}, { | ||
"id": 10, | ||
"cdnUrl": "https://akamai-perfops2.azureedge.net/500b-bench.jpg", | ||
"p": 1 | ||
}], | ||
"config": { | ||
"repeats": "30", | ||
"interval": "10" | ||
} | ||
}; | ||
}); | ||
} // eslint-disable-next-line no-unused-vars | ||
function fetchResourceListTest() { | ||
return Promise.resolve({ | ||
data: [{ | ||
id: 1, | ||
cdnUrl: 'http://localhost:9999' | ||
}] | ||
}); | ||
} | ||
@@ -324,60 +305,11 @@ | ||
function run() { | ||
var results = []; | ||
var metadata = { | ||
ua: navigator.userAgent, | ||
hostname: window.location.hostname, | ||
client: clientKey | ||
}; | ||
var storeInterval; | ||
var finished = false; | ||
var store = function store() { | ||
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
logInfo("Try to store ".concat(results.length, " items")); | ||
if (finished && results.length === 0) { | ||
logInfo('Store data interval cleared'); | ||
clearInterval(storeInterval); | ||
} | ||
if (results.length < 1) { | ||
logInfo('Batch is empty'); | ||
return; | ||
} | ||
if (results.length < 3 && !force) { | ||
logInfo('Batch is to small. Wait for more results'); | ||
return; | ||
} | ||
var slow = results.reduce(function (ac, val) { | ||
return ac + (val.time > 2000 ? 1 : 0); | ||
}, 0); // All the measurements in a batch are slow. Probably something with a user's internet connection. Skip the batch. | ||
if (slow === results.length) { | ||
logInfo("Skip batch of a ".concat(slow, " slow probes")); | ||
results.splice(0, slow); | ||
return; | ||
} | ||
storeResults(metadata, results.splice(0, results.length)).then(function () { | ||
return logInfo("Results stored"); | ||
}).catch(function (data) { | ||
var _results; | ||
return (_results = results).push.apply(_results, _toConsumableArray(data)); | ||
}); | ||
}; | ||
var numberOfRepeat = 0; | ||
var processor = function processor() { | ||
finished = false; // Clean up before new run. | ||
clearInterval(storeInterval); // Clear previous interval | ||
results = []; // Remove outdated probe results if they aren't stored till now. | ||
storeInterval = setInterval(store, STORE_DATA_INTERVAL); // Set new interval for data storing | ||
var metadata = { | ||
ua: navigator.userAgent, | ||
hostname: window.location.hostname, | ||
client: clientKey | ||
}; | ||
var results = []; | ||
fetchResourceList().then(function (response) { | ||
@@ -391,3 +323,5 @@ var chunkedData = function (array, n) { | ||
return pMapSeries(chunkedData, function (resources) { | ||
var tooSlow = 0; | ||
var down = 0; | ||
performance.clearResourceTimings(); | ||
return Promise.all(resources.map(function (resource) { | ||
@@ -397,2 +331,4 @@ return fetchResource(resource).then(function (data) { | ||
down++; | ||
} else if (data.time > 2000) { | ||
tooSlow++; | ||
} // time must be between 3 and 3000 ms | ||
@@ -406,3 +342,14 @@ // if 2 or more providers in one batch fail, drop all results | ||
results.push(data); | ||
if (results.push(data) >= QUEUE_LIMIT) { | ||
down = 0; | ||
if (tooSlow < QUEUE_LIMIT) { | ||
tooSlow = 0; | ||
} else { | ||
tooSlow = 0; | ||
return results.splice(0, results.length); | ||
} | ||
return storeResults(metadata, results.splice(0, results.length)); | ||
} | ||
}); | ||
@@ -412,6 +359,5 @@ })); | ||
}).then(logInfo, logError).then(function () { | ||
finished = true; | ||
numberOfRepeat += 1; | ||
store(true); | ||
}).then(function () { | ||
storeResults(metadata, results.splice(0, results.length)); | ||
if (numberOfRepeat < REPEAT_COUNT) { | ||
@@ -421,4 +367,4 @@ setTimeout(processor, REPEAT_DELAY); | ||
}); | ||
}; // eslint-disable-next-line comma-dangle | ||
// prettier-ignore | ||
}; // prettier-ignore | ||
// eslint-disable-next-line comma-dangle | ||
@@ -436,6 +382,3 @@ | ||
method: 'POST' | ||
}).catch(function (err) { | ||
logError(err); | ||
throw data; | ||
}); | ||
}).catch(logError); | ||
} | ||
@@ -442,0 +385,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(d){var e,a="https://devnull.perfops.net",s="https://rum-cdn.perfops.net/providers",p=3e5,u=6e4,l=3,n=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},f=n.logInfo,h=n.logError,g=window.rum?window.rum.key:void 0;function m(e){return Math.max(0,Number(e.toFixed(2)))}function b(r,e){var n=1<arguments.length&&void 0!==e?e:{},t=n.cb,o=void 0===t?function(){}:t,c=n.data,i=n.method,a=void 0===i?"GET":i,s=n.timeout,p=void 0===s?3e3:s;return new d(function(e,n){var t=new XMLHttpRequest;t.onload=function(){return e(t)},t.onerror=t.ontimeout=function(){h(t),n(new Error("Status ".concat(t.status,". Response: ").concat(t.statusText)))},t.open(a,r),t.timeout=p,o(t),t.send(c)})}function y(e){u=e.interval?1e3*parseInt(e.interval):u,e.repeats&&(l="Infinite"===e.repeats?Math.pow(2,32):parseInt(e.repeats))}function t(){function n(e){var n=0<arguments.length&&void 0!==e&&e;if(f("Try to store ".concat(o.length," items")),i&&0===o.length&&(f("Store data interval cleared"),clearInterval(r)),o.length<1)f("Batch is empty");else if(o.length<3&&!n)f("Batch is to small. Wait for more results");else{var t=o.reduce(function(e,n){return e+(2e3<n.time?1:0)},0);if(t===o.length)return f("Skip batch of a ".concat(t," slow probes")),void o.splice(0,t);(function(e,n){return b("".concat(a,"/rum/v1"),{data:JSON.stringify({metadata:e,data:n}),method:"POST"}).catch(function(e){throw h(e),n})})(c,o.splice(0,o.length)).then(function(){return f("Results stored")}).catch(function(e){var n;return(n=o).push.apply(n,_toConsumableArray(e))})}}var r,o=[],c={ua:navigator.userAgent,hostname:window.location.hostname,client:g},i=!1,t=0;setTimeout(function e(){i=!1,clearInterval(r),o=[],r=setInterval(n,1e3),function(){var n="perfops-rum-resources",e=JSON.parse(window.localStorage.getItem(n));return e&&e.expiry>Date.now()?(e.config&&y(e.config),d.resolve(e.data)):b(s).then(function(e){return JSON.parse(e.response)}).then(function(e){if(!e||!e.data||!e.data.length)throw new Error("Empty response.data");return window.localStorage.setItem(n,JSON.stringify({data:e.data,config:e.config,expiry:Date.now()+p})),e.config&&y(e.config),e.data}).catch(function(){return{data:[{id:30,cdnUrl:"https://perfops.doracdn.com/500b-db-bench.jpg",p:1},{id:38,cdnUrl:"https://perf.psychz.net/500b-bench.jpg",p:0},{id:2,cdnUrl:"https://ovh-cdn.perfops.io/500b-bench.jpg",p:1},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:0},{id:17,cdnUrl:"https://edgecast-cdn.perfops.io/500b-bench.jpg",p:1},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:0},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:1},{id:39,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:0},{id:7,cdnUrl:"https://google-cdn.perfops.io/500b-google-bench.jpg",p:1},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:1},{id:35,cdnUrl:"https://cdn81795137.blazingcdn.net/500b-blz-bench.jpg",p:1},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:1},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:1},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:1},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:1},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:1},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:1},{id:36,cdnUrl:"https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg",p:0},{id:10,cdnUrl:"https://akamai-perfops2.azureedge.net/500b-bench.jpg",p:1},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:1},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:1},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg",p:1},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:1},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:1},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:1}]}})}().then(function(e){var t;return function(e,r){return e.reduce(function(e,t){return e.then(function(n){return r(t).then(function(e){return n.push(e),n})})},d.resolve([]))}((t=e,Array.from(Array(Math.ceil(t.length/2)),function(e,n){return t.slice(2*n,2*n+2)})),function(e){var n=0;return d.all(e.map(function(e){return function(i){var a="".concat(i.cdnUrl,"?t=").concat(Date.now()),s=new URL(a).hostname;return b(a).then(function(e){var n=performance.getEntriesByName(a)[0],t={id:i.id,domain:s},r=m(n.domainLookupEnd-n.domainLookupStart),o=m(n.connectEnd-n.connectStart),c=0<o?m(n.connectEnd-n.secureConnectionStart):0;return 200<=e.status&&e.status<300&&(t=Object.assign({},t,{up:1,time:Number((n.responseEnd-n.requestStart).toFixed(2)),dnsLookupTime:r,tcpTime:o,sslTime:c,headers:e.getAllResponseHeaders()})),300<=e.status&&e.status<=500&&(t=Object.assign({},t,{up:0,dnsLookupTime:r,tcpTime:o,sslTime:c,headers:e.getAllResponseHeaders()})),t}).catch(function(){return{id:i.id,up:0}})}(e).then(function(e){e.up||n++,1<n||e.up&&(e.time<3||3e3<e.time)||o.push(e)})}))})}).then(f,h).then(function(){t+=1,n(i=!0)}).then(function(){t<l&&setTimeout(e,u)})},3e3)}e=function(){var e=["bot","headless","google","baidu","bing","msn","duckduckbot","teoma","slurp","yandex","phantomjs","pingdom","ahrefsbot"].join("|");if(new RegExp(e,"i").test(window.navigator.userAgent))console.warn("PerfOps RUM not launching due to suspicious userAgent:",window.navigator.userAgent);else if(void 0!==window.performance){if(performance.onresourcetimingbufferfull=function(){f("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof d)return t();!function(e,n){var t,r=document.createElement("script");r.onreadystatechange=r.onload=function(){t||n(),t=!0},r.setAttribute("src",e),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){d=window.ES6Promise,t()})}},"complete"===document.readyState?e():window.addEventListener("load",e)}(window.Promise); | ||
"use strict";!function(a){var n,t="https://devnull.perfops.net",c="https://rum-cdn.perfops.net/providers",i=3e5,p=6e4,s=3,e=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},d=e.logInfo,u=e.logError,h=window.rum?window.rum.key:void 0;function l(n){return Math.max(0,Number(n.toFixed(2)))}function f(r,n){var e=1<arguments.length&&void 0!==n?n:{},t=e.cb,o=void 0===t?function(){}:t,c=e.data,i=e.method,p=void 0===i?"GET":i,s=e.timeout,d=void 0===s?3e3:s;return new a(function(n,e){var t=new XMLHttpRequest;t.onload=function(){return n(t)},t.onerror=t.ontimeout=function(){u(t),e(new Error("Status ".concat(t.status,". Response: ").concat(t.statusText)))},t.open(p,r),t.timeout=d,o(t),t.send(c)})}function g(n){p=n.interval?1e3*parseInt(n.interval):p,n.repeats&&(s="Infinite"===n.repeats?Math.pow(2,32):parseInt(n.repeats))}function r(){var e=0;setTimeout(function n(){var r={ua:navigator.userAgent,hostname:window.location.hostname,client:h},o=[];(function(){var e="perfops-rum-resources",n=JSON.parse(window.localStorage.getItem(e));return n&&n.expiry>Date.now()?(n.config&&g(n.config),a.resolve(n.data)):f(c).then(function(n){return JSON.parse(n.response)}).then(function(n){if(!n||!n.data||!n.data.length)throw new Error("Empty response.data");return window.localStorage.setItem(e,JSON.stringify({data:n.data,config:n.config,expiry:Date.now()+i})),n.config&&g(n.config),n.data}).catch(function(){return{data:[{id:17,cdnUrl:"https://edgecast-cdn.perfops.io/500b-bench.jpg",p:1},{id:36,cdnUrl:"https://perfops-cc.cdn-tech.io/500b-cc-bench.jpg",p:0},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:0},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:1},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:1},{id:30,cdnUrl:"https://perfops.doracdn.com/500b-db-bench.jpg",p:1},{id:7,cdnUrl:"https://google-cdn.perfops.io/500b-google-bench.jpg",p:1},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:1},{id:35,cdnUrl:"https://cdn81795137.blazingcdn.net/500b-blz-bench.jpg",p:1},{id:2,cdnUrl:"https://ovh-cdn.perfops.io/500b-bench.jpg",p:1},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:1},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:1},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:1},{id:38,cdnUrl:"https://perf.psychz.net/500b-bench.jpg",p:0},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:1},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/ProspectOne/js-test@1.1/500b-bench.jpg",p:1},{id:39,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:0},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:1},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:1},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:1},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:1},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:1},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:0},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:1},{id:10,cdnUrl:"https://akamai-perfops2.azureedge.net/500b-bench.jpg",p:1}],config:{repeats:"30",interval:"10"}}})})().then(function(n){var t;return function(n,r){return n.reduce(function(n,t){return n.then(function(e){return r(t).then(function(n){return e.push(n),e})})},a.resolve([]))}((t=n,Array.from(Array(Math.ceil(t.length/2)),function(n,e){return t.slice(2*e,2*e+2)})),function(n){var e=0,t=0;return performance.clearResourceTimings(),a.all(n.map(function(n){return function(i){var p="".concat(i.cdnUrl,"?t=").concat(Date.now()),s=new URL(p).hostname;return f(p).then(function(n){var e=performance.getEntriesByName(p)[0],t={id:i.id,domain:s},r=l(e.domainLookupEnd-e.domainLookupStart),o=l(e.connectEnd-e.connectStart),c=0<o?l(e.connectEnd-e.secureConnectionStart):0;return 200<=n.status&&n.status<300&&(t=Object.assign({},t,{up:1,time:Number((e.responseEnd-e.requestStart).toFixed(2)),dnsLookupTime:r,tcpTime:o,sslTime:c,headers:n.getAllResponseHeaders()})),300<=n.status&&n.status<=500&&(t=Object.assign({},t,{up:0,dnsLookupTime:r,tcpTime:o,sslTime:c,headers:n.getAllResponseHeaders()})),t}).catch(function(){return{id:i.id,domain:s,up:0}})}(n).then(function(n){if(n.up?2e3<n.time&&e++:t++,!(1<t||n.up&&(n.time<3||3e3<n.time)))return 2<=o.push(n)?(t=0,e<2?(e=0,m(r,o.splice(0,o.length))):(e=0,o.splice(0,o.length))):void 0})}))})}).then(d,u).then(function(){e+=1,m(r,o.splice(0,o.length)),e<s&&setTimeout(n,p)})},3e3)}function m(n,e){return f("".concat(t,"/rum/v1"),{data:JSON.stringify({metadata:n,data:e}),method:"POST"}).catch(u)}n=function(){var n=["bot","headless","google","baidu","bing","msn","duckduckbot","teoma","slurp","yandex","phantomjs","pingdom","ahrefsbot"].join("|");if(new RegExp(n,"i").test(window.navigator.userAgent))console.warn("PerfOps RUM not launching due to suspicious userAgent:",window.navigator.userAgent);else if(void 0!==window.performance){if(performance.onresourcetimingbufferfull=function(){d("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof a)return r();!function(n,e){var t=document.createElement("script"),r=!1;t.onreadystatechange=t.onload=function(){r||e(),r=!0},t.setAttribute("src",n),document.body.appendChild(t)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){a=window.ES6Promise,r()})}},"complete"===document.readyState?n():window.addEventListener("load",n)}(window.Promise); |
{ | ||
"name": "perfops-rom", | ||
"version": "1.1.18", | ||
"version": "1.1.19", | ||
"jsdelivr": "./dist/rom3.min.js", | ||
@@ -5,0 +5,0 @@ "description": "RUM code for https://perfops.net/", |
38492
720