New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

perfops-rom

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfops-rom - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

362

dist/rom.js
"use strict";
(function (Promise) {
var QUEUE_LIMIT = 2;
var API_URL = 'https://devnull.perfops.net/rum/v1';
var RESOURCES_URL = 'https://api.perfops.net/rum-cdn.php';
var RESOURCES_TTL = 5 * 60 * 1000; // Resources list TTL in the LocalStorage
var REPEAT_DELAY = 60 * 1000; // How often the script will measure CDN performance while user staying on the same page
var QUEUE_LIMIT = 3;
var _ref = function () {

@@ -19,7 +25,7 @@ /* minified */

var clientKey = window.rum ? window.rum.key : undefined;
var globalStoreMeta = null;
var globalResults = [];
var resolvers = [];
var done = false;
function formatTiming(value) {
return Math.min(0, Number(value.toFixed(2)));
}
function fetch(url) {

@@ -78,3 +84,9 @@ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

};
var dnsLookupTime = formatTiming(timing.domainLookupEnd - timing.domainLookupStart);
var tcpTime = formatTiming(timing.connectEnd - timing.connectStart); // In Firefox if connection was cached - secure connection time is calculated
// as a difference between the page is loaded and current request execution started
// which is equal to the time spent on the page. That's why we check if actual tcp connection time is calculated.
var sslTime = tcpTime > 0 ? formatTiming(timing.connectEnd - timing.secureConnectionStart) : 0;
if (xhr.status >= 200 && xhr.status < 300) {

@@ -85,3 +97,5 @@ // Add success response measurements

time: Number((timing.responseEnd - timing.requestStart).toFixed(2)),
dnsLookupTime: Number((timing.domainLookupEnd - timing.domainLookupStart).toFixed(2)),
dnsLookupTime: dnsLookupTime,
tcpTime: tcpTime,
sslTime: sslTime,
headers: xhr.getAllResponseHeaders()

@@ -95,3 +109,5 @@ });

up: 0,
dnsLookupTime: Number((timing.domainLookupEnd - timing.domainLookupStart).toFixed(2)),
dnsLookupTime: dnsLookupTime,
tcpTime: tcpTime,
sslTime: sslTime,
headers: xhr.getAllResponseHeaders()

@@ -111,4 +127,110 @@ });

function fetchResourceList() {
return fetch('https://api.perfops.net/rum-cdn.php').then(function (xhr) {
var key = 'perfops-rum-resources';
var resources = JSON.parse(window.localStorage.getItem(key));
if (resources && resources.expiry > Date.now()) {
return Promise.resolve(resources.data);
}
return fetch(RESOURCES_URL).then(function (xhr) {
return JSON.parse(xhr.response);
}).then(function (response) {
if (!response || !response.data || !response.data.length) {
throw new Error('Empty response.data');
}
window.localStorage.setItem(key, JSON.stringify({
data: response.data,
expiry: Date.now() + RESOURCES_TTL
}));
return response.data;
}).catch(function () {
// eslint-disable-next-line
return {
"data": [{
"id": 6,
"cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 13,
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",
"p": "1"
}, {
"id": 7,
"cdnUrl": "https://googlecdn.perfstack.net/5002b-bench.jpg",
"p": "1"
}, {
"id": 1,
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",
"p": "1"
}, {
"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": 12,
"cdnUrl": "https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 2,
"cdnUrl": "https://ovhcdn.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 22,
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",
"p": "0"
}, {
"id": 17,
"cdnUrl": "https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",
"p": "1"
}, {
"id": 29,
"cdnUrl": "https://25748s.ha.azioncdn.net/500b-bench.jpg",
"p": "0"
}, {
"id": 8,
"cdnUrl": "https://perfops.gcdn.co/500b-bench.jpg",
"p": "1"
}, {
"id": 24,
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 14,
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg",
"p": "1"
}, {
"id": 20,
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg",
"p": "1"
}, {
"id": 9,
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg",
"p": "1"
}, {
"id": 15,
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",
"p": "1"
}, {
"id": 4,
"cdnUrl": "https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 18,
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg",
"p": "1"
}, {
"id": 3,
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg",
"p": "1"
}, {
"id": 10,
"cdnUrl": "https://akamai.perfstack.net/500b-bench.jpg",
"p": "1"
}]
};
});

@@ -151,100 +273,4 @@ } // eslint-disable-next-line no-unused-vars

function run() {
setTimeout(function () {
var processor = function processor() {
fetchResourceList().then(function (response) {
if (!response || !response.data || !response.data.length) {
throw new Error('Empty response.data');
}
return response;
}).catch(function () {
// eslint-disable-next-line
return {
"data": [{
"id": 13,
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",
"p": "1"
}, {
"id": 10,
"cdnUrl": "https://akamai.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 24,
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 14,
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg",
"p": "1"
}, {
"id": 22,
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",
"p": "0"
}, {
"id": 29,
"cdnUrl": "https://25748s.ha.azioncdn.net/500b-bench.jpg",
"p": "0"
}, {
"id": 1,
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",
"p": "1"
}, {
"id": 17,
"cdnUrl": "https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",
"p": "1"
}, {
"id": 9,
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg",
"p": "1"
}, {
"id": 15,
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",
"p": "1"
}, {
"id": 12,
"cdnUrl": "https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 5,
"cdnUrl": "https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",
"p": "1"
}, {
"id": 8,
"cdnUrl": "https://perfops.gcdn.co/500b-bench.jpg",
"p": "1"
}, {
"id": 3,
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg",
"p": "1"
}, {
"id": 7,
"cdnUrl": "https://googlecdn.perfstack.net/5002b-bench.jpg",
"p": "1"
}, {
"id": 2,
"cdnUrl": "https://ovhcdn.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 18,
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg",
"p": "1"
}, {
"id": 4,
"cdnUrl": "https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 6,
"cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 20,
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg",
"p": "1"
}, {
"id": 11,
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg",
"p": "1"
}]
};
}).then(function (response) {
var results = [];
var metadata = {

@@ -255,49 +281,54 @@ ua: navigator.userAgent,

};
var tooSlow = 0;
var down = 0;
return pMapSeries(response.data, function (resource) {
return fetchResource(resource).then(function (data) {
globalResults.push(data);
if (!data.up) {
down++;
} else if (data.time > 2000) {
tooSlow++;
} // time must be between 3 and 3000 ms
// if 2 or more providers in one batch fail, drop all results
var chunkedData = function (array, n) {
return Array.from(Array(Math.ceil(array.length / n)), function (_, i) {
return array.slice(i * n, i * n + n);
});
}(response, QUEUE_LIMIT);
return pMapSeries(chunkedData, function (resources) {
var results = [];
var tooSlow = 0;
var down = 0;
performance.clearResourceTimings();
return Promise.all(resources.map(function (resource) {
return fetchResource(resource).then(function (data) {
if (!data.up) {
down++;
} else if (data.time > 2000) {
tooSlow++;
} // time must be between 3 and 3000 ms
// if 2 or more providers in one batch fail, drop all results
if (down > 1 || data.up && (data.time < 3 || data.time > 3000)) {
return;
}
if (results.push(data) >= QUEUE_LIMIT) {
down = 0;
if (down > 1 || data.up && (data.time < 3 || data.time > 3000)) {
return;
}
if (tooSlow < QUEUE_LIMIT) {
tooSlow = 0;
} else {
tooSlow = 0;
return results.splice(0, results.length);
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));
}
return storeResults(metadata, results.splice(0, results.length));
}
});
}).then(function () {
if (down <= 1 && results.length) {
return storeResults(metadata, results);
}
});
}));
});
}).then(logInfo, logError).then(function () {
done = true;
resolvers.forEach(function (resolve) {
return resolve();
});
}); // eslint-disable-next-line comma-dangle
}, 1000);
return setTimeout(processor, REPEAT_DELAY);
});
}; // eslint-disable-next-line comma-dangle
setTimeout(processor, 1000);
}
function storeResults(metadata, data) {
return fetch('https://devnull.perfops.net/rum/v1', {
return fetch(API_URL, {
data: JSON.stringify({

@@ -308,4 +339,2 @@ metadata: metadata,

method: 'POST'
}).then(function (request) {
globalStoreMeta = JSON.parse(request.response);
}).catch(logError);

@@ -323,6 +352,27 @@ }

onLoad(function () {
if (typeof window.performance === 'undefined') {
/**
* Try to prevent loading the script at all for the major bots/crawlers.
* This is the first line defence against serving our scripts to crawlers.
* Warns in console if we aren't loading, to aid support.
**/
var knownBots = ['bot', 'headless', 'google', 'baidu', 'bing', 'msn', 'duckduckbot', 'teoma', 'slurp', 'yandex', 'phantomjs', 'pingdom', 'ahrefsbot'];
var botString = knownBots.join('|');
var botTestRegex = new RegExp(botString, 'i');
var isProbablyBot = botTestRegex.test(window.navigator.userAgent);
if (isProbablyBot) {
console.warn('PerfOps RUM not launching due to suspicious userAgent:', window.navigator.userAgent);
return;
}
if (typeof window.performance === 'undefined') {
return;
} // Clear performance API entries buffer when full
performance.onresourcetimingbufferfull = function () {
logInfo('clear performance resource buffer');
performance.clearResourceTimings();
};
if (typeof Promise === 'function') {

@@ -337,26 +387,2 @@ return run();

});
window.perfopsRumJs = {
getResults: function getResults() {
return new Promise(function (resolve) {
if (done) {
return resolve(globalResults);
}
resolvers.push(function () {
return resolve(globalResults);
});
});
},
getStoreMeta: function getStoreMeta() {
return new Promise(function (resolve) {
if (done) {
return resolve(globalStoreMeta);
}
resolvers.push(function () {
return resolve(globalStoreMeta);
});
});
}
};
})(window.Promise);

@@ -1,1 +0,1 @@

"use strict";!function(u){var n,t=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},e=t.logInfo,a=t.logError,c=window.rum?window.rum.key:void 0,r=null,i=[],o=[],d=!1;function p(r,n){var t=1<arguments.length&&void 0!==n?n:{},e=t.cb,o=void 0===e?function(){}:e,c=t.data,i=t.method,d=void 0===i?"GET":i,p=t.timeout,s=void 0===p?3e3:p;return new u(function(n,t){var e=new XMLHttpRequest;e.onload=function(){return n(e)},e.onerror=e.ontimeout=function(){a(e),t(new Error("Status ".concat(e.status,". Response: ").concat(e.statusText)))},e.open(d,r),e.timeout=s,o(e),e.send(c)})}function s(){setTimeout(function(){p("https://api.perfops.net/rum-cdn.php").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 n}).catch(function(){return{data:[{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:"1"},{id:10,cdnUrl:"https://akamai.perfstack.net/500b-bench.jpg",p:"1"},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:"1"},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:"1"},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:"0"},{id:29,cdnUrl:"https://25748s.ha.azioncdn.net/500b-bench.jpg",p:"0"},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:"1"},{id:17,cdnUrl:"https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",p:"1"},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:"1"},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:"1"},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:"1"},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:"1"},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:"1"},{id:7,cdnUrl:"https://googlecdn.perfstack.net/5002b-bench.jpg",p:"1"},{id:2,cdnUrl:"https://ovhcdn.perfstack.net/500b-bench.jpg",p:"1"},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:"1"},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:"1"},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:"1"},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:"1"}]}}).then(function(n){var t=[],e={ua:navigator.userAgent,hostname:window.location.hostname,client:c},r=0,o=0;return function(n,r){return n.reduce(function(n,e){return n.then(function(t){return r(e).then(function(n){return t.push(n),t})})},u.resolve([]))}(n.data,function(n){return function(r){var o="".concat(r.cdnUrl,"?t=").concat(Date.now());return p(o).then(function(n){var t=performance.getEntriesByName(o)[0],e={id:r.id};return 200<=n.status&&n.status<300&&(e=Object.assign({},e,{up:1,time:Number((t.responseEnd-t.requestStart).toFixed(2)),dnsLookupTime:Number((t.domainLookupEnd-t.domainLookupStart).toFixed(2)),headers:n.getAllResponseHeaders()})),300<=n.status&&n.status<=500&&(e=Object.assign({},e,{up:0,dnsLookupTime:Number((t.domainLookupEnd-t.domainLookupStart).toFixed(2)),headers:n.getAllResponseHeaders()})),e}).catch(function(){return{id:r.id,up:0}})}(n).then(function(n){if(i.push(n),n.up?2e3<n.time&&r++:o++,!(1<o||n.up&&(n.time<3||3e3<n.time)))return 2<=t.push(n)?(o=0,r<2?(r=0,h(e,t.splice(0,t.length))):(r=0,t.splice(0,t.length))):void 0})}).then(function(){if(o<=1&&t.length)return h(e,t)})}).then(e,a).then(function(){d=!0,o.forEach(function(n){return n()})})},1e3)}function h(n,t){return p("https://devnull.perfops.net/rum/v1",{data:JSON.stringify({metadata:n,data:t}),method:"POST"}).then(function(n){r=JSON.parse(n.response)}).catch(a)}n=function(){if(void 0!==window.performance)return"function"==typeof u?s():void function(n,t){var e,r=document.createElement("script");r.onreadystatechange=r.onload=function(){e||t(),e=!0},r.setAttribute("src",n),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){u=window.ES6Promise,s()})},"complete"===document.readyState?n():window.addEventListener("load",n),window.perfopsRumJs={getResults:function(){return new u(function(n){if(d)return n(i);o.push(function(){return n(i)})})},getStoreMeta:function(){return new u(function(n){if(d)return n(r);o.push(function(){return n(r)})})}}}(window.Promise);
"use strict";!function(a){var n,c="https://devnull.perfops.net/rum/v1",t="https://api.perfops.net/rum-cdn.php",r=3e5,e=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},o=e.logInfo,u=e.logError,i=window.rum?window.rum.key:void 0;function d(n){return Math.min(0,Number(n.toFixed(2)))}function p(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,s=void 0===i?"GET":i,d=e.timeout,p=void 0===d?3e3:d;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(s,r),t.timeout=p,o(t),t.send(c)})}function s(){setTimeout(function n(){(function(){var e="perfops-rum-resources",n=JSON.parse(window.localStorage.getItem(e));return n&&n.expiry>Date.now()?a.resolve(n.data):p(t).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,expiry:Date.now()+r})),n.data}).catch(function(){return{data:[{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:"1"},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:"1"},{id:7,cdnUrl:"https://googlecdn.perfstack.net/5002b-bench.jpg",p:"1"},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:"1"},{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:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:2,cdnUrl:"https://ovhcdn.perfstack.net/500b-bench.jpg",p:"1"},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:"0"},{id:17,cdnUrl:"https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",p:"1"},{id:29,cdnUrl:"https://25748s.ha.azioncdn.net/500b-bench.jpg",p:"0"},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:"1"},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:"1"},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:"1"},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:"1"},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:"1"},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:"1"},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:"1"},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:"1"},{id:10,cdnUrl:"https://akamai.perfstack.net/500b-bench.jpg",p:"1"}]}})})().then(function(n){var t,o={ua:navigator.userAgent,hostname:window.location.hostname,client:i};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/3)),function(n,e){return t.slice(3*e,3*e+3)})),function(n){var e=[],t=0,r=0;return performance.clearResourceTimings(),a.all(n.map(function(n){return function(i){var s="".concat(i.cdnUrl,"?t=").concat(Date.now());return p(s).then(function(n){var e=performance.getEntriesByName(s)[0],t={id:i.id},r=d(e.domainLookupEnd-e.domainLookupStart),o=d(e.connectEnd-e.connectStart),c=0<o?d(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,up:0}})}(n).then(function(n){if(n.up?2e3<n.time&&t++:r++,!(1<r||n.up&&(n.time<3||3e3<n.time)))return 3<=e.push(n)?(r=0,t<3?(t=0,function(n,e){return p(c,{data:JSON.stringify({metadata:n,data:e}),method:"POST"}).catch(u)}(o,e.splice(0,e.length))):(t=0,e.splice(0,e.length))):void 0})}))})}).then(o,u).then(function(){return setTimeout(n,6e4)})},1e3)}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(){o("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof a)return s();!function(n,e){var t,r=document.createElement("script");r.onreadystatechange=r.onload=function(){t||e(),t=!0},r.setAttribute("src",n),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){a=window.ES6Promise,s()})}},"complete"===document.readyState?n():window.addEventListener("load",n)}(window.Promise);
"use strict";
(function (Promise) {
var QUEUE_LIMIT = 2;
var API_URL = 'https://devnull.perfops.net/rum/v1';
var RESOURCES_URL = 'https://api.perfops.net/rum-cdn.php';
var RESOURCES_TTL = 5 * 60 * 1000; // Resources list TTL in the LocalStorage
var REPEAT_DELAY = 60 * 1000; // How often the script will measure CDN performance while user staying on the same page
var QUEUE_LIMIT = 3;
var _ref = function () {

@@ -19,7 +25,7 @@ /* minified */

var clientKey = window.rum ? window.rum.key : undefined;
var globalStoreMeta = null;
var globalResults = [];
var resolvers = [];
var done = false;
function formatTiming(value) {
return Math.min(0, Number(value.toFixed(2)));
}
function fetch(url) {

@@ -78,3 +84,9 @@ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

};
var dnsLookupTime = formatTiming(timing.domainLookupEnd - timing.domainLookupStart);
var tcpTime = formatTiming(timing.connectEnd - timing.connectStart); // In Firefox if connection was cached - secure connection time is calculated
// as a difference between the page is loaded and current request execution started
// which is equal to the time spent on the page. That's why we check if actual tcp connection time is calculated.
var sslTime = tcpTime > 0 ? formatTiming(timing.connectEnd - timing.secureConnectionStart) : 0;
if (xhr.status >= 200 && xhr.status < 300) {

@@ -85,3 +97,5 @@ // Add success response measurements

time: Number((timing.responseEnd - timing.requestStart).toFixed(2)),
dnsLookupTime: Number((timing.domainLookupEnd - timing.domainLookupStart).toFixed(2)),
dnsLookupTime: dnsLookupTime,
tcpTime: tcpTime,
sslTime: sslTime,
headers: xhr.getAllResponseHeaders()

@@ -95,3 +109,5 @@ });

up: 0,
dnsLookupTime: Number((timing.domainLookupEnd - timing.domainLookupStart).toFixed(2)),
dnsLookupTime: dnsLookupTime,
tcpTime: tcpTime,
sslTime: sslTime,
headers: xhr.getAllResponseHeaders()

@@ -111,4 +127,110 @@ });

function fetchResourceList() {
return fetch('https://api.perfops.net/rum-cdn.php').then(function (xhr) {
var key = 'perfops-rum-resources';
var resources = JSON.parse(window.localStorage.getItem(key));
if (resources && resources.expiry > Date.now()) {
return Promise.resolve(resources.data);
}
return fetch(RESOURCES_URL).then(function (xhr) {
return JSON.parse(xhr.response);
}).then(function (response) {
if (!response || !response.data || !response.data.length) {
throw new Error('Empty response.data');
}
window.localStorage.setItem(key, JSON.stringify({
data: response.data,
expiry: Date.now() + RESOURCES_TTL
}));
return response.data;
}).catch(function () {
// eslint-disable-next-line
return {
"data": [{
"id": 6,
"cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 13,
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",
"p": "1"
}, {
"id": 7,
"cdnUrl": "https://googlecdn.perfstack.net/5002b-bench.jpg",
"p": "1"
}, {
"id": 1,
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",
"p": "1"
}, {
"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": 12,
"cdnUrl": "https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 2,
"cdnUrl": "https://ovhcdn.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 22,
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",
"p": "0"
}, {
"id": 17,
"cdnUrl": "https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",
"p": "1"
}, {
"id": 29,
"cdnUrl": "https://25748s.ha.azioncdn.net/500b-bench.jpg",
"p": "0"
}, {
"id": 8,
"cdnUrl": "https://perfops.gcdn.co/500b-bench.jpg",
"p": "1"
}, {
"id": 24,
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 14,
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg",
"p": "1"
}, {
"id": 20,
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg",
"p": "1"
}, {
"id": 9,
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg",
"p": "1"
}, {
"id": 15,
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",
"p": "1"
}, {
"id": 4,
"cdnUrl": "https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 18,
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg",
"p": "1"
}, {
"id": 3,
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg",
"p": "1"
}, {
"id": 10,
"cdnUrl": "https://akamai.perfstack.net/500b-bench.jpg",
"p": "1"
}]
};
});

@@ -151,100 +273,4 @@ } // eslint-disable-next-line no-unused-vars

function run() {
setTimeout(function () {
var processor = function processor() {
fetchResourceList().then(function (response) {
if (!response || !response.data || !response.data.length) {
throw new Error('Empty response.data');
}
return response;
}).catch(function () {
// eslint-disable-next-line
return {
"data": [{
"id": 13,
"cdnUrl": "https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",
"p": "1"
}, {
"id": 10,
"cdnUrl": "https://akamai.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 24,
"cdnUrl": "https://img-cdnperf.mncdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 14,
"cdnUrl": "https://perfops.r.worldssl.net/500b-bench.jpg",
"p": "1"
}, {
"id": 22,
"cdnUrl": "https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",
"p": "0"
}, {
"id": 29,
"cdnUrl": "https://25748s.ha.azioncdn.net/500b-bench.jpg",
"p": "0"
}, {
"id": 1,
"cdnUrl": "https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",
"p": "1"
}, {
"id": 17,
"cdnUrl": "https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",
"p": "1"
}, {
"id": 9,
"cdnUrl": "https://1933886249.rsc.cdn77.org/500b-bench.jpg",
"p": "1"
}, {
"id": 15,
"cdnUrl": "https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",
"p": "1"
}, {
"id": 12,
"cdnUrl": "https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 5,
"cdnUrl": "https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",
"p": "1"
}, {
"id": 8,
"cdnUrl": "https://perfops.gcdn.co/500b-bench.jpg",
"p": "1"
}, {
"id": 3,
"cdnUrl": "https://perfops.perfstack.cf-china.info/500b-bench.jpg",
"p": "1"
}, {
"id": 7,
"cdnUrl": "https://googlecdn.perfstack.net/5002b-bench.jpg",
"p": "1"
}, {
"id": 2,
"cdnUrl": "https://ovhcdn.perfstack.net/500b-bench.jpg",
"p": "1"
}, {
"id": 18,
"cdnUrl": "https://azure-perfops.azureedge.net/500b-bench.jpg",
"p": "1"
}, {
"id": 4,
"cdnUrl": "https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",
"p": "1"
}, {
"id": 6,
"cdnUrl": "https://perfops-ade2.kxcdn.com/500b-bench.jpg",
"p": "1"
}, {
"id": 20,
"cdnUrl": "https://cdnperf.cachefly.net/500b-bench.jpg",
"p": "1"
}, {
"id": 11,
"cdnUrl": "https://perfops.b-cdn.net/500b-bench.jpg",
"p": "1"
}]
};
}).then(function (response) {
var results = [];
var metadata = {

@@ -255,49 +281,54 @@ ua: navigator.userAgent,

};
var tooSlow = 0;
var down = 0;
return pMapSeries(response.data, function (resource) {
return fetchResource(resource).then(function (data) {
globalResults.push(data);
if (!data.up) {
down++;
} else if (data.time > 2000) {
tooSlow++;
} // time must be between 3 and 3000 ms
// if 2 or more providers in one batch fail, drop all results
var chunkedData = function (array, n) {
return Array.from(Array(Math.ceil(array.length / n)), function (_, i) {
return array.slice(i * n, i * n + n);
});
}(response, QUEUE_LIMIT);
return pMapSeries(chunkedData, function (resources) {
var results = [];
var tooSlow = 0;
var down = 0;
performance.clearResourceTimings();
return Promise.all(resources.map(function (resource) {
return fetchResource(resource).then(function (data) {
if (!data.up) {
down++;
} else if (data.time > 2000) {
tooSlow++;
} // time must be between 3 and 3000 ms
// if 2 or more providers in one batch fail, drop all results
if (down > 1 || data.up && (data.time < 3 || data.time > 3000)) {
return;
}
if (results.push(data) >= QUEUE_LIMIT) {
down = 0;
if (down > 1 || data.up && (data.time < 3 || data.time > 3000)) {
return;
}
if (tooSlow < QUEUE_LIMIT) {
tooSlow = 0;
} else {
tooSlow = 0;
return results.splice(0, results.length);
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));
}
return storeResults(metadata, results.splice(0, results.length));
}
});
}).then(function () {
if (down <= 1 && results.length) {
return storeResults(metadata, results);
}
});
}));
});
}).then(logInfo, logError).then(function () {
done = true;
resolvers.forEach(function (resolve) {
return resolve();
});
}); // eslint-disable-next-line comma-dangle
}, 3000);
return setTimeout(processor, REPEAT_DELAY);
});
}; // eslint-disable-next-line comma-dangle
setTimeout(processor, 3000);
}
function storeResults(metadata, data) {
return fetch('https://devnull.perfops.net/rum/v1', {
return fetch(API_URL, {
data: JSON.stringify({

@@ -308,4 +339,2 @@ metadata: metadata,

method: 'POST'
}).then(function (request) {
globalStoreMeta = JSON.parse(request.response);
}).catch(logError);

@@ -323,6 +352,27 @@ }

onLoad(function () {
if (typeof window.performance === 'undefined') {
/**
* Try to prevent loading the script at all for the major bots/crawlers.
* This is the first line defence against serving our scripts to crawlers.
* Warns in console if we aren't loading, to aid support.
**/
var knownBots = ['bot', 'headless', 'google', 'baidu', 'bing', 'msn', 'duckduckbot', 'teoma', 'slurp', 'yandex', 'phantomjs', 'pingdom', 'ahrefsbot'];
var botString = knownBots.join('|');
var botTestRegex = new RegExp(botString, 'i');
var isProbablyBot = botTestRegex.test(window.navigator.userAgent);
if (isProbablyBot) {
console.warn('PerfOps RUM not launching due to suspicious userAgent:', window.navigator.userAgent);
return;
}
if (typeof window.performance === 'undefined') {
return;
} // Clear performance API entries buffer when full
performance.onresourcetimingbufferfull = function () {
logInfo('clear performance resource buffer');
performance.clearResourceTimings();
};
if (typeof Promise === 'function') {

@@ -337,26 +387,2 @@ return run();

});
window.perfopsRumJs = {
getResults: function getResults() {
return new Promise(function (resolve) {
if (done) {
return resolve(globalResults);
}
resolvers.push(function () {
return resolve(globalResults);
});
});
},
getStoreMeta: function getStoreMeta() {
return new Promise(function (resolve) {
if (done) {
return resolve(globalStoreMeta);
}
resolvers.push(function () {
return resolve(globalStoreMeta);
});
});
}
};
})(window.Promise);

@@ -1,1 +0,1 @@

"use strict";!function(u){var n,t=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},e=t.logInfo,a=t.logError,c=window.rum?window.rum.key:void 0,r=null,i=[],o=[],d=!1;function p(r,n){var t=1<arguments.length&&void 0!==n?n:{},e=t.cb,o=void 0===e?function(){}:e,c=t.data,i=t.method,d=void 0===i?"GET":i,p=t.timeout,s=void 0===p?3e3:p;return new u(function(n,t){var e=new XMLHttpRequest;e.onload=function(){return n(e)},e.onerror=e.ontimeout=function(){a(e),t(new Error("Status ".concat(e.status,". Response: ").concat(e.statusText)))},e.open(d,r),e.timeout=s,o(e),e.send(c)})}function s(){setTimeout(function(){p("https://api.perfops.net/rum-cdn.php").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 n}).catch(function(){return{data:[{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:"1"},{id:10,cdnUrl:"https://akamai.perfstack.net/500b-bench.jpg",p:"1"},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:"1"},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:"1"},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:"0"},{id:29,cdnUrl:"https://25748s.ha.azioncdn.net/500b-bench.jpg",p:"0"},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:"1"},{id:17,cdnUrl:"https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",p:"1"},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:"1"},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:"1"},{id:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:5,cdnUrl:"https://d2axgrpnciinw7.cloudfront.net/500b-bench.jpg",p:"1"},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:"1"},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:"1"},{id:7,cdnUrl:"https://googlecdn.perfstack.net/5002b-bench.jpg",p:"1"},{id:2,cdnUrl:"https://ovhcdn.perfstack.net/500b-bench.jpg",p:"1"},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:"1"},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:"1"},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:"1"},{id:11,cdnUrl:"https://perfops.b-cdn.net/500b-bench.jpg",p:"1"}]}}).then(function(n){var t=[],e={ua:navigator.userAgent,hostname:window.location.hostname,client:c},r=0,o=0;return function(n,r){return n.reduce(function(n,e){return n.then(function(t){return r(e).then(function(n){return t.push(n),t})})},u.resolve([]))}(n.data,function(n){return function(r){var o="".concat(r.cdnUrl,"?t=").concat(Date.now());return p(o).then(function(n){var t=performance.getEntriesByName(o)[0],e={id:r.id};return 200<=n.status&&n.status<300&&(e=Object.assign({},e,{up:1,time:Number((t.responseEnd-t.requestStart).toFixed(2)),dnsLookupTime:Number((t.domainLookupEnd-t.domainLookupStart).toFixed(2)),headers:n.getAllResponseHeaders()})),300<=n.status&&n.status<=500&&(e=Object.assign({},e,{up:0,dnsLookupTime:Number((t.domainLookupEnd-t.domainLookupStart).toFixed(2)),headers:n.getAllResponseHeaders()})),e}).catch(function(){return{id:r.id,up:0}})}(n).then(function(n){if(i.push(n),n.up?2e3<n.time&&r++:o++,!(1<o||n.up&&(n.time<3||3e3<n.time)))return 2<=t.push(n)?(o=0,r<2?(r=0,h(e,t.splice(0,t.length))):(r=0,t.splice(0,t.length))):void 0})}).then(function(){if(o<=1&&t.length)return h(e,t)})}).then(e,a).then(function(){d=!0,o.forEach(function(n){return n()})})},3e3)}function h(n,t){return p("https://devnull.perfops.net/rum/v1",{data:JSON.stringify({metadata:n,data:t}),method:"POST"}).then(function(n){r=JSON.parse(n.response)}).catch(a)}n=function(){if(void 0!==window.performance)return"function"==typeof u?s():void function(n,t){var e,r=document.createElement("script");r.onreadystatechange=r.onload=function(){e||t(),e=!0},r.setAttribute("src",n),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){u=window.ES6Promise,s()})},"complete"===document.readyState?n():window.addEventListener("load",n),window.perfopsRumJs={getResults:function(){return new u(function(n){if(d)return n(i);o.push(function(){return n(i)})})},getStoreMeta:function(){return new u(function(n){if(d)return n(r);o.push(function(){return n(r)})})}}}(window.Promise);
"use strict";!function(a){var n,c="https://devnull.perfops.net/rum/v1",t="https://api.perfops.net/rum-cdn.php",r=3e5,e=-1!==function(){}.toString().indexOf("minified")?{logInfo:console.log,logError:console.error}:{logInfo:function(){},logError:function(){}},o=e.logInfo,u=e.logError,i=window.rum?window.rum.key:void 0;function d(n){return Math.min(0,Number(n.toFixed(2)))}function p(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,s=void 0===i?"GET":i,d=e.timeout,p=void 0===d?3e3:d;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(s,r),t.timeout=p,o(t),t.send(c)})}function s(){setTimeout(function n(){(function(){var e="perfops-rum-resources",n=JSON.parse(window.localStorage.getItem(e));return n&&n.expiry>Date.now()?a.resolve(n.data):p(t).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,expiry:Date.now()+r})),n.data}).catch(function(){return{data:[{id:6,cdnUrl:"https://perfops-ade2.kxcdn.com/500b-bench.jpg",p:"1"},{id:13,cdnUrl:"https://m9d7v5r2.map2.ssl.hwcdn.net/500b-bench.jpg",p:"1"},{id:7,cdnUrl:"https://googlecdn.perfstack.net/5002b-bench.jpg",p:"1"},{id:1,cdnUrl:"https://kgmni17536myjst.belugacdn.link/500b-bench.jpg",p:"1"},{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:12,cdnUrl:"https://cdn.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:2,cdnUrl:"https://ovhcdn.perfstack.net/500b-bench.jpg",p:"1"},{id:22,cdnUrl:"https://09d3da8545e855ce.cdn.gocache.net/500b-bench.jpg",p:"0"},{id:17,cdnUrl:"https://edgecast.perfstack.net/8086B5F/bench/500b-bench.jpg",p:"1"},{id:29,cdnUrl:"https://25748s.ha.azioncdn.net/500b-bench.jpg",p:"0"},{id:8,cdnUrl:"https://perfops.gcdn.co/500b-bench.jpg",p:"1"},{id:24,cdnUrl:"https://img-cdnperf.mncdn.com/500b-bench.jpg",p:"1"},{id:14,cdnUrl:"https://perfops.r.worldssl.net/500b-bench.jpg",p:"1"},{id:20,cdnUrl:"https://cdnperf.cachefly.net/500b-bench.jpg",p:"1"},{id:9,cdnUrl:"https://1933886249.rsc.cdn77.org/500b-bench.jpg",p:"1"},{id:15,cdnUrl:"https://cdnperf-rum.cdnetworks.net/500b-bench.jpg",p:"1"},{id:4,cdnUrl:"https://fastly.jsdelivr.net/gh/jimaek/js-test@1.1/500b-bench.jpg",p:"1"},{id:18,cdnUrl:"https://azure-perfops.azureedge.net/500b-bench.jpg",p:"1"},{id:3,cdnUrl:"https://perfops.perfstack.cf-china.info/500b-bench.jpg",p:"1"},{id:10,cdnUrl:"https://akamai.perfstack.net/500b-bench.jpg",p:"1"}]}})})().then(function(n){var t,o={ua:navigator.userAgent,hostname:window.location.hostname,client:i};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/3)),function(n,e){return t.slice(3*e,3*e+3)})),function(n){var e=[],t=0,r=0;return performance.clearResourceTimings(),a.all(n.map(function(n){return function(i){var s="".concat(i.cdnUrl,"?t=").concat(Date.now());return p(s).then(function(n){var e=performance.getEntriesByName(s)[0],t={id:i.id},r=d(e.domainLookupEnd-e.domainLookupStart),o=d(e.connectEnd-e.connectStart),c=0<o?d(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,up:0}})}(n).then(function(n){if(n.up?2e3<n.time&&t++:r++,!(1<r||n.up&&(n.time<3||3e3<n.time)))return 3<=e.push(n)?(r=0,t<3?(t=0,function(n,e){return p(c,{data:JSON.stringify({metadata:n,data:e}),method:"POST"}).catch(u)}(o,e.splice(0,e.length))):(t=0,e.splice(0,e.length))):void 0})}))})}).then(o,u).then(function(){return setTimeout(n,6e4)})},3e3)}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(){o("clear performance resource buffer"),performance.clearResourceTimings()},"function"==typeof a)return s();!function(n,e){var t,r=document.createElement("script");r.onreadystatechange=r.onload=function(){t||e(),t=!0},r.setAttribute("src",n),document.body.appendChild(r)}("https://cdn.jsdelivr.net/npm/es6-promise@4.2.4/dist/es6-promise.min.js",function(){a=window.ES6Promise,s()})}},"complete"===document.readyState?n():window.addEventListener("load",n)}(window.Promise);
{
"name": "perfops-rom",
"version": "1.1.1",
"version": "1.1.2",
"jsdelivr": "./dist/rom3.min.js",

@@ -5,0 +5,0 @@ "description": "RUM code for https://perfops.net/",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc