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

statful-client-javascript

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statful-client-javascript - npm Package Compare versions

Comparing version 2.0.4 to 2.1.0

yarn.lock

580

dist/statful.js
/**
* statful-client-javascript 2.0.4
* statful-client-javascript 2.1.0
* Copyright 2017 Statful <https://www.statful.com/>

@@ -9,566 +9,2 @@ */

/* eslint-env browser,amd,node */
//
// usertiming.js
//
// A polyfill for UserTiming (http://www.w3.org/TR/user-timing/)
//
// Copyright 2013 Nic Jansma
// http://nicj.net
//
// https://github.com/nicjansma/usertiming.js
//
// Licensed under the MIT license
//
(function (window) {
"use strict";
// allow running in Node.js environment
if (typeof window === "undefined") {
window = {};
}
// prepare base perf object
if (typeof window.performance === "undefined") {
window.performance = {};
}
// We need to keep a global reference to the window.performance object to
// prevent any added properties from being garbage-collected in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137407
window._perfRefForUserTimingPolyfill = window.performance;
//
// Note what we shimmed
//
window.performance.userTimingJsNow = false;
window.performance.userTimingJsNowPrefixed = false;
window.performance.userTimingJsUserTiming = false;
window.performance.userTimingJsUserTimingPrefixed = false;
window.performance.userTimingJsPerformanceTimeline = false;
window.performance.userTimingJsPerformanceTimelinePrefixed = false;
// for prefixed support
var prefixes = [];
var methods = [];
var methodTest = null;
var i, j;
//
// window.performance.now() shim
// http://www.w3.org/TR/hr-time/
//
if (typeof window.performance.now !== "function") {
window.performance.userTimingJsNow = true;
// copy prefixed version over if it exists
methods = ["webkitNow", "msNow", "mozNow"];
for (i = 0; i < methods.length; i++) {
if (typeof window.performance[methods[i]] === "function") {
window.performance.now = window.performance[methods[i]];
window.performance.userTimingJsNowPrefixed = true;
break;
}
}
//
// now() should be a DOMHighResTimeStamp, which is defined as being a time relative
// to navigationStart of the PerformanceTiming (PT) interface. If this browser supports
// PT, use that as our relative start. Otherwise, use "now" as the start and all other
// now() calls will be relative to our initialization.
//
var nowOffset = +new Date();
if (window.performance.timing && window.performance.timing.navigationStart) {
nowOffset = window.performance.timing.navigationStart;
} else if (typeof process !== "undefined" && typeof process.hrtime === "function") {
nowOffset = process.hrtime();
window.performance.now = function () {
var time = process.hrtime(nowOffset);
return time[0] * 1e3 + time[1] * 1e-6;
};
}
if (typeof window.performance.now !== "function") {
// No browser support, fall back to Date.now
if (Date.now) {
window.performance.now = function () {
return Date.now() - nowOffset;
};
} else {
// no Date.now support, get the time from new Date()
window.performance.now = function () {
return +new Date() - nowOffset;
};
}
}
}
//
// PerformanceTimeline (PT) shims
// http://www.w3.org/TR/performance-timeline/
//
/**
* Adds an object to our internal Performance Timeline array.
*
* Will be blank if the environment supports PT.
*/
var addToPerformanceTimeline = function addToPerformanceTimeline() {};
/**
* Clears the specified entry types from our timeline array.
*
* Will be blank if the environment supports PT.
*/
var clearEntriesFromPerformanceTimeline = function clearEntriesFromPerformanceTimeline() {};
// performance timeline array
var performanceTimeline = [];
// whether or not the timeline will require sort on getEntries()
var performanceTimelineRequiresSort = false;
// whether or not ResourceTiming is natively supported but UserTiming is
// not (eg Firefox 35)
var hasNativeGetEntriesButNotUserTiming = false;
//
// If getEntries() and mark() aren't defined, we'll assume
// we have to shim at least some PT functions.
//
if (typeof window.performance.getEntries !== "function" || typeof window.performance.mark !== "function") {
if (typeof window.performance.getEntries === "function" && typeof window.performance.mark !== "function") {
hasNativeGetEntriesButNotUserTiming = true;
}
window.performance.userTimingJsPerformanceTimeline = true;
// copy prefixed version over if it exists
prefixes = ["webkit", "moz"];
methods = ["getEntries", "getEntriesByName", "getEntriesByType"];
for (i = 0; i < methods.length; i++) {
for (j = 0; j < prefixes.length; j++) {
// prefixed method will likely have an upper-case first letter
methodTest = prefixes[j] + methods[i].substr(0, 1).toUpperCase() + methods[i].substr(1);
if (typeof window.performance[methodTest] === "function") {
window.performance[methods[i]] = window.performance[methodTest];
window.performance.userTimingJsPerformanceTimelinePrefixed = true;
}
}
}
/**
* Adds an object to our internal Performance Timeline array.
*
* @param {Object} obj PerformanceEntry
*/
addToPerformanceTimeline = function addToPerformanceTimeline(obj) {
performanceTimeline.push(obj);
//
// If we insert a measure, its startTime may be out of order
// from the rest of the entries because the use can use any
// mark as the start time. If so, note we have to sort it before
// returning getEntries();
//
if (obj.entryType === "measure") {
performanceTimelineRequiresSort = true;
}
};
/**
* Ensures our PT array is in the correct sorted order (by startTime)
*/
var ensurePerformanceTimelineOrder = function ensurePerformanceTimelineOrder() {
if (!performanceTimelineRequiresSort) {
return;
}
//
// Measures, which may be in this list, may enter the list in
// an unsorted order. For example:
//
// 1. measure("a")
// 2. mark("start_mark")
// 3. measure("b", "start_mark")
// 4. measure("c")
// 5. getEntries()
//
// When calling #5, we should return [a,c,b] because technically the start time
// of c is "0" (navigationStart), which will occur before b's start time due to the mark.
//
performanceTimeline.sort(function (a, b) {
return a.startTime - b.startTime;
});
performanceTimelineRequiresSort = false;
};
/**
* Clears the specified entry types from our timeline array.
*
* @param {string} entryType Entry type (eg "mark" or "measure")
* @param {string} [name] Entry name (optional)
*/
clearEntriesFromPerformanceTimeline = function clearEntriesFromPerformanceTimeline(entryType, name) {
// clear all entries from the perf timeline
i = 0;
while (i < performanceTimeline.length) {
if (performanceTimeline[i].entryType !== entryType) {
// unmatched entry type
i++;
continue;
}
if (typeof name !== "undefined" && performanceTimeline[i].name !== name) {
// unmatched name
i++;
continue;
}
// this entry matches our criteria, remove just it
performanceTimeline.splice(i, 1);
}
};
if (typeof window.performance.getEntries !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntries = window.performance.getEntries;
/**
* Gets all entries from the Performance Timeline.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentries
*
* NOTE: This will only ever return marks and measures.
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntries = function () {
ensurePerformanceTimelineOrder();
// get a copy of all of our entries
var entries = performanceTimeline.slice(0);
// if there was a native version of getEntries, add that
if (hasNativeGetEntriesButNotUserTiming && origGetEntries) {
// merge in native
Array.prototype.push.apply(entries, origGetEntries.call(window.performance));
// sort by startTime
entries.sort(function (a, b) {
return a.startTime - b.startTime;
});
}
return entries;
};
}
if (typeof window.performance.getEntriesByType !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntriesByType = window.performance.getEntriesByType;
/**
* Gets all entries from the Performance Timeline of the specified type.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentriesbytype
*
* NOTE: This will only work for marks and measures.
*
* @param {string} entryType Entry type (eg "mark" or "measure")
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntriesByType = function (entryType) {
// we only support marks/measures
if (typeof entryType === "undefined" || entryType !== "mark" && entryType !== "measure") {
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByType) {
// native version exists, forward
return origGetEntriesByType.call(window.performance, entryType);
}
return [];
}
// see note in ensurePerformanceTimelineOrder() on why this is required
if (entryType === "measure") {
ensurePerformanceTimelineOrder();
}
// find all entries of entryType
var entries = [];
for (i = 0; i < performanceTimeline.length; i++) {
if (performanceTimeline[i].entryType === entryType) {
entries.push(performanceTimeline[i]);
}
}
return entries;
};
}
if (typeof window.performance.getEntriesByName !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntriesByName = window.performance.getEntriesByName;
/**
* Gets all entries from the Performance Timeline of the specified
* name, and optionally, type.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentriesbyname
*
* NOTE: This will only work for marks and measures.
*
* @param {string} name Entry name
* @param {string} [entryType] Entry type (eg "mark" or "measure")
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntriesByName = function (name, entryType) {
if (entryType && entryType !== "mark" && entryType !== "measure") {
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByName) {
// native version exists, forward
return origGetEntriesByName.call(window.performance, name, entryType);
}
return [];
}
// see note in ensurePerformanceTimelineOrder() on why this is required
if (typeof entryType !== "undefined" && entryType === "measure") {
ensurePerformanceTimelineOrder();
}
// find all entries of the name and (optionally) type
var entries = [];
for (i = 0; i < performanceTimeline.length; i++) {
if (typeof entryType !== "undefined" && performanceTimeline[i].entryType !== entryType) {
continue;
}
if (performanceTimeline[i].name === name) {
entries.push(performanceTimeline[i]);
}
}
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByName) {
// merge in native
Array.prototype.push.apply(entries, origGetEntriesByName.call(window.performance, name, entryType));
// sort by startTime
entries.sort(function (a, b) {
return a.startTime - b.startTime;
});
}
return entries;
};
}
}
//
// UserTiming support
//
if (typeof window.performance.mark !== "function") {
window.performance.userTimingJsUserTiming = true;
// copy prefixed version over if it exists
prefixes = ["webkit", "moz", "ms"];
methods = ["mark", "measure", "clearMarks", "clearMeasures"];
for (i = 0; i < methods.length; i++) {
for (j = 0; j < prefixes.length; j++) {
// prefixed method will likely have an upper-case first letter
methodTest = prefixes[j] + methods[i].substr(0, 1).toUpperCase() + methods[i].substr(1);
if (typeof window.performance[methodTest] === "function") {
window.performance[methods[i]] = window.performance[methodTest];
window.performance.userTimingJsUserTimingPrefixed = true;
}
}
}
// only used for measure(), to quickly see the latest timestamp of a mark
var marks = {};
if (typeof window.performance.mark !== "function") {
/**
* UserTiming mark
* http://www.w3.org/TR/user-timing/#dom-performance-mark
*
* @param {string} markName Mark name
*/
window.performance.mark = function (markName) {
var now = window.performance.now();
// mark name is required
if (typeof markName === "undefined") {
throw new SyntaxError("Mark name must be specified");
}
// mark name can't be a NT timestamp
if (window.performance.timing && markName in window.performance.timing) {
throw new SyntaxError("Mark name is not allowed");
}
if (!marks[markName]) {
marks[markName] = [];
}
marks[markName].push(now);
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "mark",
name: markName,
startTime: now,
duration: 0
});
};
}
if (typeof window.performance.clearMarks !== "function") {
/**
* UserTiming clear marks
* http://www.w3.org/TR/user-timing/#dom-performance-clearmarks
*
* @param {string} markName Mark name
*/
window.performance.clearMarks = function (markName) {
if (!markName) {
// clear all marks
marks = {};
} else {
marks[markName] = [];
}
clearEntriesFromPerformanceTimeline("mark", markName);
};
}
if (typeof window.performance.measure !== "function") {
/**
* UserTiming measure
* http://www.w3.org/TR/user-timing/#dom-performance-measure
*
* @param {string} measureName Measure name
* @param {string} [startMark] Start mark name
* @param {string} [endMark] End mark name
*/
window.performance.measure = function (measureName, startMark, endMark) {
var now = window.performance.now();
if (typeof measureName === "undefined") {
throw new SyntaxError("Measure must be specified");
}
// if there isn't a startMark, we measure from navigationStart to now
if (!startMark) {
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "measure",
name: measureName,
startTime: 0,
duration: now
});
return;
}
//
// If there is a startMark, check for it first in the NavigationTiming interface,
// then check our own marks.
//
var startMarkTime = 0;
if (window.performance.timing && startMark in window.performance.timing) {
// mark cannot have a timing of 0
if (startMark !== "navigationStart" && window.performance.timing[startMark] === 0) {
throw new Error(startMark + " has a timing of 0");
}
// time is the offset of this mark to navigationStart's time
startMarkTime = window.performance.timing[startMark] - window.performance.timing.navigationStart;
} else if (startMark in marks) {
startMarkTime = marks[startMark][marks[startMark].length - 1];
} else {
throw new Error(startMark + " mark not found");
}
//
// If there is a endMark, check for it first in the NavigationTiming interface,
// then check our own marks.
//
var endMarkTime = now;
if (endMark) {
endMarkTime = 0;
if (window.performance.timing && endMark in window.performance.timing) {
// mark cannot have a timing of 0
if (endMark !== "navigationStart" && window.performance.timing[endMark] === 0) {
throw new Error(endMark + " has a timing of 0");
}
// time is the offset of this mark to navigationStart's time
endMarkTime = window.performance.timing[endMark] - window.performance.timing.navigationStart;
} else if (endMark in marks) {
endMarkTime = marks[endMark][marks[endMark].length - 1];
} else {
throw new Error(endMark + " mark not found");
}
}
// add to our measure array
var duration = endMarkTime - startMarkTime;
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "measure",
name: measureName,
startTime: startMarkTime,
duration: duration
});
};
}
if (typeof window.performance.clearMeasures !== "function") {
/**
* UserTiming clear measures
* http://www.w3.org/TR/user-timing/#dom-performance-clearmeasures
*
* @param {string} measureName Measure name
*/
window.performance.clearMeasures = function (measureName) {
clearEntriesFromPerformanceTimeline("measure", measureName);
};
}
}
//
// Export UserTiming to the appropriate location.
//
// When included directly via a script tag in the browser, we're good as we've been
// updating the window.performance object.
//
if (typeof define === "function" && define.amd) {
//
// AMD / RequireJS
//
define([], function () {
return window.performance;
});
} else if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
//
// Node.js
//
module.exports = window.performance;
}
})(typeof window !== "undefined" ? window : undefined);
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -1057,16 +493,2 @@ return typeof obj;

/**
* Clear resources
*/
}, {
key: 'clearResources',
value: function clearResources() {
try {
window.performance.clearResourceTimings();
} catch (ex) {
this.logger.error(ex);
}
}
/**
* Clear measures

@@ -1073,0 +495,0 @@ * @param {Array} measures - list of measures to clear (optional)

/**
* statful-client-javascript 2.0.4
* statful-client-javascript 2.1.0
* Copyright 2017 Statful <https://www.statful.com/>
*/
var statful=function(){"use strict";!function(e){void 0===e&&(e={}),void 0===e.performance&&(e.performance={}),e._perfRefForUserTimingPolyfill=e.performance,e.performance.userTimingJsNow=!1,e.performance.userTimingJsNowPrefixed=!1,e.performance.userTimingJsUserTiming=!1,e.performance.userTimingJsUserTimingPrefixed=!1,e.performance.userTimingJsPerformanceTimeline=!1,e.performance.userTimingJsPerformanceTimelinePrefixed=!1;var r,n,t=[],i=[],a=null;if("function"!=typeof e.performance.now){for(e.performance.userTimingJsNow=!0,i=["webkitNow","msNow","mozNow"],r=0;r<i.length;r++)if("function"==typeof e.performance[i[r]]){e.performance.now=e.performance[i[r]],e.performance.userTimingJsNowPrefixed=!0;break}var o=+new Date;e.performance.timing&&e.performance.timing.navigationStart?o=e.performance.timing.navigationStart:"undefined"!=typeof process&&"function"==typeof process.hrtime&&(o=process.hrtime(),e.performance.now=function(){var e=process.hrtime(o);return 1e3*e[0]+1e-6*e[1]}),"function"!=typeof e.performance.now&&(Date.now?e.performance.now=function(){return Date.now()-o}:e.performance.now=function(){return+new Date-o})}var s=function(){},u=function(){},c=[],f=!1,g=!1;if("function"!=typeof e.performance.getEntries||"function"!=typeof e.performance.mark){for("function"==typeof e.performance.getEntries&&"function"!=typeof e.performance.mark&&(g=!0),e.performance.userTimingJsPerformanceTimeline=!0,t=["webkit","moz"],i=["getEntries","getEntriesByName","getEntriesByType"],r=0;r<i.length;r++)for(n=0;n<t.length;n++)a=t[n]+i[r].substr(0,1).toUpperCase()+i[r].substr(1),"function"==typeof e.performance[a]&&(e.performance[i[r]]=e.performance[a],e.performance.userTimingJsPerformanceTimelinePrefixed=!0);s=function(e){c.push(e),"measure"===e.entryType&&(f=!0)};var m=function(){f&&(c.sort(function(e,r){return e.startTime-r.startTime}),f=!1)};if(u=function(e,n){for(r=0;r<c.length;)c[r].entryType===e&&(void 0===n||c[r].name===n)?c.splice(r,1):r++},"function"!=typeof e.performance.getEntries||g){var l=e.performance.getEntries;e.performance.getEntries=function(){m();var r=c.slice(0);return g&&l&&(Array.prototype.push.apply(r,l.call(e.performance)),r.sort(function(e,r){return e.startTime-r.startTime})),r}}if("function"!=typeof e.performance.getEntriesByType||g){var p=e.performance.getEntriesByType;e.performance.getEntriesByType=function(n){if(void 0===n||"mark"!==n&&"measure"!==n)return g&&p?p.call(e.performance,n):[];"measure"===n&&m();var t=[];for(r=0;r<c.length;r++)c[r].entryType===n&&t.push(c[r]);return t}}if("function"!=typeof e.performance.getEntriesByName||g){var d=e.performance.getEntriesByName;e.performance.getEntriesByName=function(n,t){if(t&&"mark"!==t&&"measure"!==t)return g&&d?d.call(e.performance,n,t):[];void 0!==t&&"measure"===t&&m();var i=[];for(r=0;r<c.length;r++)void 0!==t&&c[r].entryType!==t||c[r].name===n&&i.push(c[r]);return g&&d&&(Array.prototype.push.apply(i,d.call(e.performance,n,t)),i.sort(function(e,r){return e.startTime-r.startTime})),i}}}if("function"!=typeof e.performance.mark){for(e.performance.userTimingJsUserTiming=!0,t=["webkit","moz","ms"],i=["mark","measure","clearMarks","clearMeasures"],r=0;r<i.length;r++)for(n=0;n<t.length;n++)a=t[n]+i[r].substr(0,1).toUpperCase()+i[r].substr(1),"function"==typeof e.performance[a]&&(e.performance[i[r]]=e.performance[a],e.performance.userTimingJsUserTimingPrefixed=!0);var h={};"function"!=typeof e.performance.mark&&(e.performance.mark=function(r){var n=e.performance.now();if(void 0===r)throw new SyntaxError("Mark name must be specified");if(e.performance.timing&&r in e.performance.timing)throw new SyntaxError("Mark name is not allowed");h[r]||(h[r]=[]),h[r].push(n),s({entryType:"mark",name:r,startTime:n,duration:0})}),"function"!=typeof e.performance.clearMarks&&(e.performance.clearMarks=function(e){e?h[e]=[]:h={},u("mark",e)}),"function"!=typeof e.performance.measure&&(e.performance.measure=function(r,n,t){var i=e.performance.now();if(void 0===r)throw new SyntaxError("Measure must be specified");if(n){var a=0;if(e.performance.timing&&n in e.performance.timing){if("navigationStart"!==n&&0===e.performance.timing[n])throw new Error(n+" has a timing of 0");a=e.performance.timing[n]-e.performance.timing.navigationStart}else{if(!(n in h))throw new Error(n+" mark not found");a=h[n][h[n].length-1]}var o=i;if(t)if(o=0,e.performance.timing&&t in e.performance.timing){if("navigationStart"!==t&&0===e.performance.timing[t])throw new Error(t+" has a timing of 0");o=e.performance.timing[t]-e.performance.timing.navigationStart}else{if(!(t in h))throw new Error(t+" mark not found");o=h[t][h[t].length-1]}s({entryType:"measure",name:r,startTime:a,duration:o-a})}else s({entryType:"measure",name:r,startTime:0,duration:i})}),"function"!=typeof e.performance.clearMeasures&&(e.performance.clearMeasures=function(e){u("measure",e)})}"function"==typeof define&&define.amd?define([],function(){return e.performance}):"undefined"!=typeof module&&void 0!==module.exports&&(module.exports=e.performance)}("undefined"!=typeof window?window:void 0);var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},n=function(){function e(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(r,n,t){return n&&e(r.prototype,n),t&&e(r,t),r}}(),t=function(){function e(n){r(this,e),this.debugEnabled=n||!1}return n(e,[{key:"info",value:function(){this.debugEnabled&&console.info.apply(console,Array.prototype.slice.call(arguments))}},{key:"debug",value:function(){this.debugEnabled&&console.debug.apply(console,Array.prototype.slice.call(arguments))}},{key:"error",value:function(){this.debugEnabled&&console.error.apply(console,Array.prototype.slice.call(arguments))}}]),e}(),i=function(){function e(n){r(this,e),this.config={},Object.assign(this.config,n),this.logger=new t(this.config.debug),this.config&&this.config.flushInterval&&this.registerQueue(this.config.flushInterval)}return n(e,[{key:"sendData",value:function(e){var r=this,n=this.config.apiAddress+"/beacon/metrics",t=JSON.stringify(e);if(this.config.dryrun)this.logger.debug("Dryrun data",e);else{var i=new XMLHttpRequest;i.open("POST",n,!0),i.timeout=this.config.timeout,i.setRequestHeader("Content-type","application/json"),i.send(t),i.onreadystatechange=function(){200==i.status||201==i.status?r.logger.debug("Successfully send metric"):r.logger.debug("Error send metric",n,i.status)}}}},{key:"registerQueue",value:function(e){var r=this,n=void 0;return this.metricsQueue=[],"number"==typeof e&&e>0&&(n=setInterval(function(){r.metricsQueue.length>0&&(r.sendData(r.metricsQueue),r.metricsQueue=[])},e),window.addEventListener("beforeunload",function(){clearInterval(n)}),!0)}},{key:"addMetric",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&"function"==typeof e.isValid&&e.isValid()?this.shouldAddMetric(e)?r?this.metricsQueue.push(e):this.sendData([e]):this.logger.debug("Metric was discarded due to sample rate."):this.logger.error("Invalid metric.")}},{key:"shouldAddMetric",value:function(){var e=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).sampleRate||this.config.sampleRate||100)/100;return Math.random()<=e}}]),e}(),a=["avg","count","sum","first","last","p90","p95","min","max"],o=[10,30,60,120,180,300],s=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};r(this,e),this.name=n,this.type=t,this.value=i;var s=[],u=[],c=0;o[t]&&(s=o[t].tags,u=o[t].aggregations,c=o[t].aggregationFrequency),this.tags=this.buildTags(a.tags,o.tags,s,o.app),this.aggregations=this.buildAggregations(a.aggregations,o.aggregations,u),this.aggregationFrequency=this.buildAggregationFrequency(a.aggregationFrequency,o.aggregationFrequency,c),this.namespace=a.namespace||o.namespace,this.sampleRate=a.sampleRate||o.sampleRate}return n(e,[{key:"buildTags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=arguments[3],i={};return Object.assign(i,r),Object.assign(i,n),Object.assign(i,e),!i.app&&t&&(i.app=t),i}},{key:"buildAggregations",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],t=[];return t=t.concat(r),t=t.concat(n).filter(this.uniq),t=t.concat(e).filter(this.uniq),this.filterAggregations(t)}},{key:"uniq",value:function(e,r,n){return e&&n.indexOf(e)===r}},{key:"buildAggregationFrequency",value:function(e,r,n){var t=e||n||r;return this.filterAggregationFrequency(t)}},{key:"filterAggregations",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return a.includes(e)})}},{key:"filterAggregationFrequency",value:function(e){return o.includes(e)?e:10}},{key:"isValid",value:function(){return!(isNaN(this.value)||!this.name)}}]),e}(),u={dryrun:!1,debug:!1,app:void 0,namespace:"web",tags:{},aggregations:[],aggregationFrequency:10,timer:{tags:{unit:"ms"},aggregations:["avg","p90","count"]},counter:{tags:{},aggregations:["sum","count"]},gauge:{tags:{},aggregations:["last"]},timeout:2e3,flushInterval:1e4,sampleRate:100};return function(){function a(){r(this,a)}return n(a,null,[{key:"initialize",value:function(r){this.config={apiAddress:"https://beacon.statful.com"},"object"===(void 0===r?"undefined":e(r))&&null!==r||(r={}),Object.assign(this.config,u),Object.assign(this.config,r),this.logger=new t(this.config.debug),this.util=new i(this.config)}},{key:"measureTimeUserTiming",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=window.performance.getEntriesByName(e).filter(function(e){return"measure"===e.entryType}),n=void 0;return r.length>0?n=r[r.length-1].duration:this.logger.debug("Measure "+e+" not found"),n}},{key:"clearMarks",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMarks(e)}):window.performance.clearMarks()}catch(e){this.logger.error(e)}}},{key:"clearResources",value:function(){try{window.performance.clearResourceTimings()}catch(e){this.logger.error(e)}}},{key:"clearMeasures",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMeasures(e)}):window.performance.clearMeasures()}catch(e){this.logger.error(e)}}},{key:"registerMark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{this.logger.debug("Register Mark",e),e?window.performance.mark(e):this.logger.error("Undefined resource name to register as a mark")}catch(e){this.logger.error(e)}}},{key:"registerMeasure",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{if(this.logger.debug("Register Measure",e,r,n),e){var t={clearMarks:!1,clearMeasures:!1};Object.assign(t,n),t.endMark||(this.registerMark(e),t.endMark=e),window.performance.measure(e,t.startMark,t.endMark);var i=this.measureTimeUserTiming(e);if(i){var a=new s(r,"timer",i,t,this.config);this.util.addMetric(a,!0)}else this.logger.error("Failed to get measure time to register as timer value");t.clearMarks&&this.clearMarks([t.startMark,t.endMark]),t.clearMeasures&&this.clearMeasures([e])}else this.logger.error("Undefined resource name to register as a measure")}catch(e){this.logger.error(e)}}},{key:"timer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Timer",e,r,n);var t=new s(e,"timer",r,n,this.config);this.util.addMetric(t,!0)}},{key:"counter",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Counter",e,n);var t=new s(e,"counter",r,n,this.config);t.value=Math.abs(parseInt(t.value,10)),this.util.addMetric(t,!0)}},{key:"gauge",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Gauge",e,r,n);var t=new s(e,"gauge",r,n,this.config);this.util.addMetric(t,!0)}},{key:"sendMetric",value:function(e,r,n){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=new s(r,e,n,t,this.config);this.util.addMetric(i,!1)}}]),a}()}();
var statful=function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),i=function(){function e(r){t(this,e),this.debugEnabled=r||!1}return r(e,[{key:"info",value:function(){this.debugEnabled&&console.info.apply(console,Array.prototype.slice.call(arguments))}},{key:"debug",value:function(){this.debugEnabled&&console.debug.apply(console,Array.prototype.slice.call(arguments))}},{key:"error",value:function(){this.debugEnabled&&console.error.apply(console,Array.prototype.slice.call(arguments))}}]),e}(),n=function(){function e(r){t(this,e),this.config={},Object.assign(this.config,r),this.logger=new i(this.config.debug),this.config&&this.config.flushInterval&&this.registerQueue(this.config.flushInterval)}return r(e,[{key:"sendData",value:function(e){var t=this,r=this.config.apiAddress+"/beacon/metrics",i=JSON.stringify(e);if(this.config.dryrun)this.logger.debug("Dryrun data",e);else{var n=new XMLHttpRequest;n.open("POST",r,!0),n.timeout=this.config.timeout,n.setRequestHeader("Content-type","application/json"),n.send(i),n.onreadystatechange=function(){200==n.status||201==n.status?t.logger.debug("Successfully send metric"):t.logger.debug("Error send metric",r,n.status)}}}},{key:"registerQueue",value:function(e){var t=this,r=void 0;return this.metricsQueue=[],"number"==typeof e&&e>0&&(r=setInterval(function(){t.metricsQueue.length>0&&(t.sendData(t.metricsQueue),t.metricsQueue=[])},e),window.addEventListener("beforeunload",function(){clearInterval(r)}),!0)}},{key:"addMetric",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&"function"==typeof e.isValid&&e.isValid()?this.shouldAddMetric(e)?t?this.metricsQueue.push(e):this.sendData([e]):this.logger.debug("Metric was discarded due to sample rate."):this.logger.error("Invalid metric.")}},{key:"shouldAddMetric",value:function(){var e=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).sampleRate||this.config.sampleRate||100)/100;return Math.random()<=e}}]),e}(),a=["avg","count","sum","first","last","p90","p95","min","max"],s=[10,30,60,120,180,300],o=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};t(this,e),this.name=r,this.type=i,this.value=n;var o=[],u=[],g=0;s[i]&&(o=s[i].tags,u=s[i].aggregations,g=s[i].aggregationFrequency),this.tags=this.buildTags(a.tags,s.tags,o,s.app),this.aggregations=this.buildAggregations(a.aggregations,s.aggregations,u),this.aggregationFrequency=this.buildAggregationFrequency(a.aggregationFrequency,s.aggregationFrequency,g),this.namespace=a.namespace||s.namespace,this.sampleRate=a.sampleRate||s.sampleRate}return r(e,[{key:"buildTags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments[3],n={};return Object.assign(n,t),Object.assign(n,r),Object.assign(n,e),!n.app&&i&&(n.app=i),n}},{key:"buildAggregations",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=[];return i=i.concat(t),i=i.concat(r).filter(this.uniq),i=i.concat(e).filter(this.uniq),this.filterAggregations(i)}},{key:"uniq",value:function(e,t,r){return e&&r.indexOf(e)===t}},{key:"buildAggregationFrequency",value:function(e,t,r){var i=e||r||t;return this.filterAggregationFrequency(i)}},{key:"filterAggregations",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return a.includes(e)})}},{key:"filterAggregationFrequency",value:function(e){return s.includes(e)?e:10}},{key:"isValid",value:function(){return!(isNaN(this.value)||!this.name)}}]),e}(),u={dryrun:!1,debug:!1,app:void 0,namespace:"web",tags:{},aggregations:[],aggregationFrequency:10,timer:{tags:{unit:"ms"},aggregations:["avg","p90","count"]},counter:{tags:{},aggregations:["sum","count"]},gauge:{tags:{},aggregations:["last"]},timeout:2e3,flushInterval:1e4,sampleRate:100};return function(){function a(){t(this,a)}return r(a,null,[{key:"initialize",value:function(t){this.config={apiAddress:"https://beacon.statful.com"},"object"===(void 0===t?"undefined":e(t))&&null!==t||(t={}),Object.assign(this.config,u),Object.assign(this.config,t),this.logger=new i(this.config.debug),this.util=new n(this.config)}},{key:"measureTimeUserTiming",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=window.performance.getEntriesByName(e).filter(function(e){return"measure"===e.entryType}),r=void 0;return t.length>0?r=t[t.length-1].duration:this.logger.debug("Measure "+e+" not found"),r}},{key:"clearMarks",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMarks(e)}):window.performance.clearMarks()}catch(e){this.logger.error(e)}}},{key:"clearMeasures",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMeasures(e)}):window.performance.clearMeasures()}catch(e){this.logger.error(e)}}},{key:"registerMark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{this.logger.debug("Register Mark",e),e?window.performance.mark(e):this.logger.error("Undefined resource name to register as a mark")}catch(e){this.logger.error(e)}}},{key:"registerMeasure",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{if(this.logger.debug("Register Measure",e,t,r),e){var i={clearMarks:!1,clearMeasures:!1};Object.assign(i,r),i.endMark||(this.registerMark(e),i.endMark=e),window.performance.measure(e,i.startMark,i.endMark);var n=this.measureTimeUserTiming(e);if(n){var a=new o(t,"timer",n,i,this.config);this.util.addMetric(a,!0)}else this.logger.error("Failed to get measure time to register as timer value");i.clearMarks&&this.clearMarks([i.startMark,i.endMark]),i.clearMeasures&&this.clearMeasures([e])}else this.logger.error("Undefined resource name to register as a measure")}catch(e){this.logger.error(e)}}},{key:"timer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Timer",e,t,r);var i=new o(e,"timer",t,r,this.config);this.util.addMetric(i,!0)}},{key:"counter",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Counter",e,r);var i=new o(e,"counter",t,r,this.config);i.value=Math.abs(parseInt(i.value,10)),this.util.addMetric(i,!0)}},{key:"gauge",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Gauge",e,t,r);var i=new o(e,"gauge",t,r,this.config);this.util.addMetric(i,!0)}},{key:"sendMetric",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=new o(t,e,r,i,this.config);this.util.addMetric(n,!1)}}]),a}()}();
/**
* statful-client-javascript 2.0.4
* statful-client-javascript 2.1.0
* Copyright 2017 Statful <https://www.statful.com/>

@@ -12,566 +12,2 @@ */

/* eslint-env browser,amd,node */
//
// usertiming.js
//
// A polyfill for UserTiming (http://www.w3.org/TR/user-timing/)
//
// Copyright 2013 Nic Jansma
// http://nicj.net
//
// https://github.com/nicjansma/usertiming.js
//
// Licensed under the MIT license
//
(function (window) {
"use strict";
// allow running in Node.js environment
if (typeof window === "undefined") {
window = {};
}
// prepare base perf object
if (typeof window.performance === "undefined") {
window.performance = {};
}
// We need to keep a global reference to the window.performance object to
// prevent any added properties from being garbage-collected in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137407
window._perfRefForUserTimingPolyfill = window.performance;
//
// Note what we shimmed
//
window.performance.userTimingJsNow = false;
window.performance.userTimingJsNowPrefixed = false;
window.performance.userTimingJsUserTiming = false;
window.performance.userTimingJsUserTimingPrefixed = false;
window.performance.userTimingJsPerformanceTimeline = false;
window.performance.userTimingJsPerformanceTimelinePrefixed = false;
// for prefixed support
var prefixes = [];
var methods = [];
var methodTest = null;
var i, j;
//
// window.performance.now() shim
// http://www.w3.org/TR/hr-time/
//
if (typeof window.performance.now !== "function") {
window.performance.userTimingJsNow = true;
// copy prefixed version over if it exists
methods = ["webkitNow", "msNow", "mozNow"];
for (i = 0; i < methods.length; i++) {
if (typeof window.performance[methods[i]] === "function") {
window.performance.now = window.performance[methods[i]];
window.performance.userTimingJsNowPrefixed = true;
break;
}
}
//
// now() should be a DOMHighResTimeStamp, which is defined as being a time relative
// to navigationStart of the PerformanceTiming (PT) interface. If this browser supports
// PT, use that as our relative start. Otherwise, use "now" as the start and all other
// now() calls will be relative to our initialization.
//
var nowOffset = +new Date();
if (window.performance.timing && window.performance.timing.navigationStart) {
nowOffset = window.performance.timing.navigationStart;
} else if (typeof process !== "undefined" && typeof process.hrtime === "function") {
nowOffset = process.hrtime();
window.performance.now = function () {
var time = process.hrtime(nowOffset);
return time[0] * 1e3 + time[1] * 1e-6;
};
}
if (typeof window.performance.now !== "function") {
// No browser support, fall back to Date.now
if (Date.now) {
window.performance.now = function () {
return Date.now() - nowOffset;
};
} else {
// no Date.now support, get the time from new Date()
window.performance.now = function () {
return +new Date() - nowOffset;
};
}
}
}
//
// PerformanceTimeline (PT) shims
// http://www.w3.org/TR/performance-timeline/
//
/**
* Adds an object to our internal Performance Timeline array.
*
* Will be blank if the environment supports PT.
*/
var addToPerformanceTimeline = function addToPerformanceTimeline() {};
/**
* Clears the specified entry types from our timeline array.
*
* Will be blank if the environment supports PT.
*/
var clearEntriesFromPerformanceTimeline = function clearEntriesFromPerformanceTimeline() {};
// performance timeline array
var performanceTimeline = [];
// whether or not the timeline will require sort on getEntries()
var performanceTimelineRequiresSort = false;
// whether or not ResourceTiming is natively supported but UserTiming is
// not (eg Firefox 35)
var hasNativeGetEntriesButNotUserTiming = false;
//
// If getEntries() and mark() aren't defined, we'll assume
// we have to shim at least some PT functions.
//
if (typeof window.performance.getEntries !== "function" || typeof window.performance.mark !== "function") {
if (typeof window.performance.getEntries === "function" && typeof window.performance.mark !== "function") {
hasNativeGetEntriesButNotUserTiming = true;
}
window.performance.userTimingJsPerformanceTimeline = true;
// copy prefixed version over if it exists
prefixes = ["webkit", "moz"];
methods = ["getEntries", "getEntriesByName", "getEntriesByType"];
for (i = 0; i < methods.length; i++) {
for (j = 0; j < prefixes.length; j++) {
// prefixed method will likely have an upper-case first letter
methodTest = prefixes[j] + methods[i].substr(0, 1).toUpperCase() + methods[i].substr(1);
if (typeof window.performance[methodTest] === "function") {
window.performance[methods[i]] = window.performance[methodTest];
window.performance.userTimingJsPerformanceTimelinePrefixed = true;
}
}
}
/**
* Adds an object to our internal Performance Timeline array.
*
* @param {Object} obj PerformanceEntry
*/
addToPerformanceTimeline = function addToPerformanceTimeline(obj) {
performanceTimeline.push(obj);
//
// If we insert a measure, its startTime may be out of order
// from the rest of the entries because the use can use any
// mark as the start time. If so, note we have to sort it before
// returning getEntries();
//
if (obj.entryType === "measure") {
performanceTimelineRequiresSort = true;
}
};
/**
* Ensures our PT array is in the correct sorted order (by startTime)
*/
var ensurePerformanceTimelineOrder = function ensurePerformanceTimelineOrder() {
if (!performanceTimelineRequiresSort) {
return;
}
//
// Measures, which may be in this list, may enter the list in
// an unsorted order. For example:
//
// 1. measure("a")
// 2. mark("start_mark")
// 3. measure("b", "start_mark")
// 4. measure("c")
// 5. getEntries()
//
// When calling #5, we should return [a,c,b] because technically the start time
// of c is "0" (navigationStart), which will occur before b's start time due to the mark.
//
performanceTimeline.sort(function (a, b) {
return a.startTime - b.startTime;
});
performanceTimelineRequiresSort = false;
};
/**
* Clears the specified entry types from our timeline array.
*
* @param {string} entryType Entry type (eg "mark" or "measure")
* @param {string} [name] Entry name (optional)
*/
clearEntriesFromPerformanceTimeline = function clearEntriesFromPerformanceTimeline(entryType, name) {
// clear all entries from the perf timeline
i = 0;
while (i < performanceTimeline.length) {
if (performanceTimeline[i].entryType !== entryType) {
// unmatched entry type
i++;
continue;
}
if (typeof name !== "undefined" && performanceTimeline[i].name !== name) {
// unmatched name
i++;
continue;
}
// this entry matches our criteria, remove just it
performanceTimeline.splice(i, 1);
}
};
if (typeof window.performance.getEntries !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntries = window.performance.getEntries;
/**
* Gets all entries from the Performance Timeline.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentries
*
* NOTE: This will only ever return marks and measures.
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntries = function () {
ensurePerformanceTimelineOrder();
// get a copy of all of our entries
var entries = performanceTimeline.slice(0);
// if there was a native version of getEntries, add that
if (hasNativeGetEntriesButNotUserTiming && origGetEntries) {
// merge in native
Array.prototype.push.apply(entries, origGetEntries.call(window.performance));
// sort by startTime
entries.sort(function (a, b) {
return a.startTime - b.startTime;
});
}
return entries;
};
}
if (typeof window.performance.getEntriesByType !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntriesByType = window.performance.getEntriesByType;
/**
* Gets all entries from the Performance Timeline of the specified type.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentriesbytype
*
* NOTE: This will only work for marks and measures.
*
* @param {string} entryType Entry type (eg "mark" or "measure")
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntriesByType = function (entryType) {
// we only support marks/measures
if (typeof entryType === "undefined" || entryType !== "mark" && entryType !== "measure") {
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByType) {
// native version exists, forward
return origGetEntriesByType.call(window.performance, entryType);
}
return [];
}
// see note in ensurePerformanceTimelineOrder() on why this is required
if (entryType === "measure") {
ensurePerformanceTimelineOrder();
}
// find all entries of entryType
var entries = [];
for (i = 0; i < performanceTimeline.length; i++) {
if (performanceTimeline[i].entryType === entryType) {
entries.push(performanceTimeline[i]);
}
}
return entries;
};
}
if (typeof window.performance.getEntriesByName !== "function" || hasNativeGetEntriesButNotUserTiming) {
var origGetEntriesByName = window.performance.getEntriesByName;
/**
* Gets all entries from the Performance Timeline of the specified
* name, and optionally, type.
* http://www.w3.org/TR/performance-timeline/#dom-performance-getentriesbyname
*
* NOTE: This will only work for marks and measures.
*
* @param {string} name Entry name
* @param {string} [entryType] Entry type (eg "mark" or "measure")
*
* @returns {PerformanceEntry[]} Array of PerformanceEntrys
*/
window.performance.getEntriesByName = function (name, entryType) {
if (entryType && entryType !== "mark" && entryType !== "measure") {
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByName) {
// native version exists, forward
return origGetEntriesByName.call(window.performance, name, entryType);
}
return [];
}
// see note in ensurePerformanceTimelineOrder() on why this is required
if (typeof entryType !== "undefined" && entryType === "measure") {
ensurePerformanceTimelineOrder();
}
// find all entries of the name and (optionally) type
var entries = [];
for (i = 0; i < performanceTimeline.length; i++) {
if (typeof entryType !== "undefined" && performanceTimeline[i].entryType !== entryType) {
continue;
}
if (performanceTimeline[i].name === name) {
entries.push(performanceTimeline[i]);
}
}
if (hasNativeGetEntriesButNotUserTiming && origGetEntriesByName) {
// merge in native
Array.prototype.push.apply(entries, origGetEntriesByName.call(window.performance, name, entryType));
// sort by startTime
entries.sort(function (a, b) {
return a.startTime - b.startTime;
});
}
return entries;
};
}
}
//
// UserTiming support
//
if (typeof window.performance.mark !== "function") {
window.performance.userTimingJsUserTiming = true;
// copy prefixed version over if it exists
prefixes = ["webkit", "moz", "ms"];
methods = ["mark", "measure", "clearMarks", "clearMeasures"];
for (i = 0; i < methods.length; i++) {
for (j = 0; j < prefixes.length; j++) {
// prefixed method will likely have an upper-case first letter
methodTest = prefixes[j] + methods[i].substr(0, 1).toUpperCase() + methods[i].substr(1);
if (typeof window.performance[methodTest] === "function") {
window.performance[methods[i]] = window.performance[methodTest];
window.performance.userTimingJsUserTimingPrefixed = true;
}
}
}
// only used for measure(), to quickly see the latest timestamp of a mark
var marks = {};
if (typeof window.performance.mark !== "function") {
/**
* UserTiming mark
* http://www.w3.org/TR/user-timing/#dom-performance-mark
*
* @param {string} markName Mark name
*/
window.performance.mark = function (markName) {
var now = window.performance.now();
// mark name is required
if (typeof markName === "undefined") {
throw new SyntaxError("Mark name must be specified");
}
// mark name can't be a NT timestamp
if (window.performance.timing && markName in window.performance.timing) {
throw new SyntaxError("Mark name is not allowed");
}
if (!marks[markName]) {
marks[markName] = [];
}
marks[markName].push(now);
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "mark",
name: markName,
startTime: now,
duration: 0
});
};
}
if (typeof window.performance.clearMarks !== "function") {
/**
* UserTiming clear marks
* http://www.w3.org/TR/user-timing/#dom-performance-clearmarks
*
* @param {string} markName Mark name
*/
window.performance.clearMarks = function (markName) {
if (!markName) {
// clear all marks
marks = {};
} else {
marks[markName] = [];
}
clearEntriesFromPerformanceTimeline("mark", markName);
};
}
if (typeof window.performance.measure !== "function") {
/**
* UserTiming measure
* http://www.w3.org/TR/user-timing/#dom-performance-measure
*
* @param {string} measureName Measure name
* @param {string} [startMark] Start mark name
* @param {string} [endMark] End mark name
*/
window.performance.measure = function (measureName, startMark, endMark) {
var now = window.performance.now();
if (typeof measureName === "undefined") {
throw new SyntaxError("Measure must be specified");
}
// if there isn't a startMark, we measure from navigationStart to now
if (!startMark) {
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "measure",
name: measureName,
startTime: 0,
duration: now
});
return;
}
//
// If there is a startMark, check for it first in the NavigationTiming interface,
// then check our own marks.
//
var startMarkTime = 0;
if (window.performance.timing && startMark in window.performance.timing) {
// mark cannot have a timing of 0
if (startMark !== "navigationStart" && window.performance.timing[startMark] === 0) {
throw new Error(startMark + " has a timing of 0");
}
// time is the offset of this mark to navigationStart's time
startMarkTime = window.performance.timing[startMark] - window.performance.timing.navigationStart;
} else if (startMark in marks) {
startMarkTime = marks[startMark][marks[startMark].length - 1];
} else {
throw new Error(startMark + " mark not found");
}
//
// If there is a endMark, check for it first in the NavigationTiming interface,
// then check our own marks.
//
var endMarkTime = now;
if (endMark) {
endMarkTime = 0;
if (window.performance.timing && endMark in window.performance.timing) {
// mark cannot have a timing of 0
if (endMark !== "navigationStart" && window.performance.timing[endMark] === 0) {
throw new Error(endMark + " has a timing of 0");
}
// time is the offset of this mark to navigationStart's time
endMarkTime = window.performance.timing[endMark] - window.performance.timing.navigationStart;
} else if (endMark in marks) {
endMarkTime = marks[endMark][marks[endMark].length - 1];
} else {
throw new Error(endMark + " mark not found");
}
}
// add to our measure array
var duration = endMarkTime - startMarkTime;
// add to perf timeline as well
addToPerformanceTimeline({
entryType: "measure",
name: measureName,
startTime: startMarkTime,
duration: duration
});
};
}
if (typeof window.performance.clearMeasures !== "function") {
/**
* UserTiming clear measures
* http://www.w3.org/TR/user-timing/#dom-performance-clearmeasures
*
* @param {string} measureName Measure name
*/
window.performance.clearMeasures = function (measureName) {
clearEntriesFromPerformanceTimeline("measure", measureName);
};
}
}
//
// Export UserTiming to the appropriate location.
//
// When included directly via a script tag in the browser, we're good as we've been
// updating the window.performance object.
//
if (typeof define === "function" && define.amd) {
//
// AMD / RequireJS
//
define([], function () {
return window.performance;
});
} else if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
//
// Node.js
//
module.exports = window.performance;
}
})(typeof window !== "undefined" ? window : undefined);
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -1060,16 +496,2 @@ return typeof obj;

/**
* Clear resources
*/
}, {
key: 'clearResources',
value: function clearResources() {
try {
window.performance.clearResourceTimings();
} catch (ex) {
this.logger.error(ex);
}
}
/**
* Clear measures

@@ -1076,0 +498,0 @@ * @param {Array} measures - list of measures to clear (optional)

/**
* statful-client-javascript 2.0.4
* statful-client-javascript 2.1.0
* Copyright 2017 Statful <https://www.statful.com/>
*/
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.statful=r()}(this,function(){"use strict";!function(e){void 0===e&&(e={}),void 0===e.performance&&(e.performance={}),e._perfRefForUserTimingPolyfill=e.performance,e.performance.userTimingJsNow=!1,e.performance.userTimingJsNowPrefixed=!1,e.performance.userTimingJsUserTiming=!1,e.performance.userTimingJsUserTimingPrefixed=!1,e.performance.userTimingJsPerformanceTimeline=!1,e.performance.userTimingJsPerformanceTimelinePrefixed=!1;var r,n,t=[],i=[],a=null;if("function"!=typeof e.performance.now){for(e.performance.userTimingJsNow=!0,i=["webkitNow","msNow","mozNow"],r=0;r<i.length;r++)if("function"==typeof e.performance[i[r]]){e.performance.now=e.performance[i[r]],e.performance.userTimingJsNowPrefixed=!0;break}var o=+new Date;e.performance.timing&&e.performance.timing.navigationStart?o=e.performance.timing.navigationStart:"undefined"!=typeof process&&"function"==typeof process.hrtime&&(o=process.hrtime(),e.performance.now=function(){var e=process.hrtime(o);return 1e3*e[0]+1e-6*e[1]}),"function"!=typeof e.performance.now&&(Date.now?e.performance.now=function(){return Date.now()-o}:e.performance.now=function(){return+new Date-o})}var s=function(){},u=function(){},c=[],f=!1,g=!1;if("function"!=typeof e.performance.getEntries||"function"!=typeof e.performance.mark){for("function"==typeof e.performance.getEntries&&"function"!=typeof e.performance.mark&&(g=!0),e.performance.userTimingJsPerformanceTimeline=!0,t=["webkit","moz"],i=["getEntries","getEntriesByName","getEntriesByType"],r=0;r<i.length;r++)for(n=0;n<t.length;n++)a=t[n]+i[r].substr(0,1).toUpperCase()+i[r].substr(1),"function"==typeof e.performance[a]&&(e.performance[i[r]]=e.performance[a],e.performance.userTimingJsPerformanceTimelinePrefixed=!0);s=function(e){c.push(e),"measure"===e.entryType&&(f=!0)};var m=function(){f&&(c.sort(function(e,r){return e.startTime-r.startTime}),f=!1)};if(u=function(e,n){for(r=0;r<c.length;)c[r].entryType===e&&(void 0===n||c[r].name===n)?c.splice(r,1):r++},"function"!=typeof e.performance.getEntries||g){var l=e.performance.getEntries;e.performance.getEntries=function(){m();var r=c.slice(0);return g&&l&&(Array.prototype.push.apply(r,l.call(e.performance)),r.sort(function(e,r){return e.startTime-r.startTime})),r}}if("function"!=typeof e.performance.getEntriesByType||g){var p=e.performance.getEntriesByType;e.performance.getEntriesByType=function(n){if(void 0===n||"mark"!==n&&"measure"!==n)return g&&p?p.call(e.performance,n):[];"measure"===n&&m();var t=[];for(r=0;r<c.length;r++)c[r].entryType===n&&t.push(c[r]);return t}}if("function"!=typeof e.performance.getEntriesByName||g){var d=e.performance.getEntriesByName;e.performance.getEntriesByName=function(n,t){if(t&&"mark"!==t&&"measure"!==t)return g&&d?d.call(e.performance,n,t):[];void 0!==t&&"measure"===t&&m();var i=[];for(r=0;r<c.length;r++)void 0!==t&&c[r].entryType!==t||c[r].name===n&&i.push(c[r]);return g&&d&&(Array.prototype.push.apply(i,d.call(e.performance,n,t)),i.sort(function(e,r){return e.startTime-r.startTime})),i}}}if("function"!=typeof e.performance.mark){for(e.performance.userTimingJsUserTiming=!0,t=["webkit","moz","ms"],i=["mark","measure","clearMarks","clearMeasures"],r=0;r<i.length;r++)for(n=0;n<t.length;n++)a=t[n]+i[r].substr(0,1).toUpperCase()+i[r].substr(1),"function"==typeof e.performance[a]&&(e.performance[i[r]]=e.performance[a],e.performance.userTimingJsUserTimingPrefixed=!0);var h={};"function"!=typeof e.performance.mark&&(e.performance.mark=function(r){var n=e.performance.now();if(void 0===r)throw new SyntaxError("Mark name must be specified");if(e.performance.timing&&r in e.performance.timing)throw new SyntaxError("Mark name is not allowed");h[r]||(h[r]=[]),h[r].push(n),s({entryType:"mark",name:r,startTime:n,duration:0})}),"function"!=typeof e.performance.clearMarks&&(e.performance.clearMarks=function(e){e?h[e]=[]:h={},u("mark",e)}),"function"!=typeof e.performance.measure&&(e.performance.measure=function(r,n,t){var i=e.performance.now();if(void 0===r)throw new SyntaxError("Measure must be specified");if(n){var a=0;if(e.performance.timing&&n in e.performance.timing){if("navigationStart"!==n&&0===e.performance.timing[n])throw new Error(n+" has a timing of 0");a=e.performance.timing[n]-e.performance.timing.navigationStart}else{if(!(n in h))throw new Error(n+" mark not found");a=h[n][h[n].length-1]}var o=i;if(t)if(o=0,e.performance.timing&&t in e.performance.timing){if("navigationStart"!==t&&0===e.performance.timing[t])throw new Error(t+" has a timing of 0");o=e.performance.timing[t]-e.performance.timing.navigationStart}else{if(!(t in h))throw new Error(t+" mark not found");o=h[t][h[t].length-1]}s({entryType:"measure",name:r,startTime:a,duration:o-a})}else s({entryType:"measure",name:r,startTime:0,duration:i})}),"function"!=typeof e.performance.clearMeasures&&(e.performance.clearMeasures=function(e){u("measure",e)})}"function"==typeof define&&define.amd?define([],function(){return e.performance}):"undefined"!=typeof module&&void 0!==module.exports&&(module.exports=e.performance)}("undefined"!=typeof window?window:void 0);var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},n=function(){function e(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(r,n,t){return n&&e(r.prototype,n),t&&e(r,t),r}}(),t=function(){function e(n){r(this,e),this.debugEnabled=n||!1}return n(e,[{key:"info",value:function(){this.debugEnabled&&console.info.apply(console,Array.prototype.slice.call(arguments))}},{key:"debug",value:function(){this.debugEnabled&&console.debug.apply(console,Array.prototype.slice.call(arguments))}},{key:"error",value:function(){this.debugEnabled&&console.error.apply(console,Array.prototype.slice.call(arguments))}}]),e}(),i=function(){function e(n){r(this,e),this.config={},Object.assign(this.config,n),this.logger=new t(this.config.debug),this.config&&this.config.flushInterval&&this.registerQueue(this.config.flushInterval)}return n(e,[{key:"sendData",value:function(e){var r=this,n=this.config.apiAddress+"/beacon/metrics",t=JSON.stringify(e);if(this.config.dryrun)this.logger.debug("Dryrun data",e);else{var i=new XMLHttpRequest;i.open("POST",n,!0),i.timeout=this.config.timeout,i.setRequestHeader("Content-type","application/json"),i.send(t),i.onreadystatechange=function(){200==i.status||201==i.status?r.logger.debug("Successfully send metric"):r.logger.debug("Error send metric",n,i.status)}}}},{key:"registerQueue",value:function(e){var r=this,n=void 0;return this.metricsQueue=[],"number"==typeof e&&e>0&&(n=setInterval(function(){r.metricsQueue.length>0&&(r.sendData(r.metricsQueue),r.metricsQueue=[])},e),window.addEventListener("beforeunload",function(){clearInterval(n)}),!0)}},{key:"addMetric",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&"function"==typeof e.isValid&&e.isValid()?this.shouldAddMetric(e)?r?this.metricsQueue.push(e):this.sendData([e]):this.logger.debug("Metric was discarded due to sample rate."):this.logger.error("Invalid metric.")}},{key:"shouldAddMetric",value:function(){var e=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).sampleRate||this.config.sampleRate||100)/100;return Math.random()<=e}}]),e}(),a=["avg","count","sum","first","last","p90","p95","min","max"],o=[10,30,60,120,180,300],s=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};r(this,e),this.name=n,this.type=t,this.value=i;var s=[],u=[],c=0;o[t]&&(s=o[t].tags,u=o[t].aggregations,c=o[t].aggregationFrequency),this.tags=this.buildTags(a.tags,o.tags,s,o.app),this.aggregations=this.buildAggregations(a.aggregations,o.aggregations,u),this.aggregationFrequency=this.buildAggregationFrequency(a.aggregationFrequency,o.aggregationFrequency,c),this.namespace=a.namespace||o.namespace,this.sampleRate=a.sampleRate||o.sampleRate}return n(e,[{key:"buildTags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=arguments[3],i={};return Object.assign(i,r),Object.assign(i,n),Object.assign(i,e),!i.app&&t&&(i.app=t),i}},{key:"buildAggregations",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],t=[];return t=t.concat(r),t=t.concat(n).filter(this.uniq),t=t.concat(e).filter(this.uniq),this.filterAggregations(t)}},{key:"uniq",value:function(e,r,n){return e&&n.indexOf(e)===r}},{key:"buildAggregationFrequency",value:function(e,r,n){var t=e||n||r;return this.filterAggregationFrequency(t)}},{key:"filterAggregations",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return a.includes(e)})}},{key:"filterAggregationFrequency",value:function(e){return o.includes(e)?e:10}},{key:"isValid",value:function(){return!(isNaN(this.value)||!this.name)}}]),e}(),u={dryrun:!1,debug:!1,app:void 0,namespace:"web",tags:{},aggregations:[],aggregationFrequency:10,timer:{tags:{unit:"ms"},aggregations:["avg","p90","count"]},counter:{tags:{},aggregations:["sum","count"]},gauge:{tags:{},aggregations:["last"]},timeout:2e3,flushInterval:1e4,sampleRate:100};return function(){function a(){r(this,a)}return n(a,null,[{key:"initialize",value:function(r){this.config={apiAddress:"https://beacon.statful.com"},"object"===(void 0===r?"undefined":e(r))&&null!==r||(r={}),Object.assign(this.config,u),Object.assign(this.config,r),this.logger=new t(this.config.debug),this.util=new i(this.config)}},{key:"measureTimeUserTiming",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=window.performance.getEntriesByName(e).filter(function(e){return"measure"===e.entryType}),n=void 0;return r.length>0?n=r[r.length-1].duration:this.logger.debug("Measure "+e+" not found"),n}},{key:"clearMarks",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMarks(e)}):window.performance.clearMarks()}catch(e){this.logger.error(e)}}},{key:"clearResources",value:function(){try{window.performance.clearResourceTimings()}catch(e){this.logger.error(e)}}},{key:"clearMeasures",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMeasures(e)}):window.performance.clearMeasures()}catch(e){this.logger.error(e)}}},{key:"registerMark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{this.logger.debug("Register Mark",e),e?window.performance.mark(e):this.logger.error("Undefined resource name to register as a mark")}catch(e){this.logger.error(e)}}},{key:"registerMeasure",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{if(this.logger.debug("Register Measure",e,r,n),e){var t={clearMarks:!1,clearMeasures:!1};Object.assign(t,n),t.endMark||(this.registerMark(e),t.endMark=e),window.performance.measure(e,t.startMark,t.endMark);var i=this.measureTimeUserTiming(e);if(i){var a=new s(r,"timer",i,t,this.config);this.util.addMetric(a,!0)}else this.logger.error("Failed to get measure time to register as timer value");t.clearMarks&&this.clearMarks([t.startMark,t.endMark]),t.clearMeasures&&this.clearMeasures([e])}else this.logger.error("Undefined resource name to register as a measure")}catch(e){this.logger.error(e)}}},{key:"timer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Timer",e,r,n);var t=new s(e,"timer",r,n,this.config);this.util.addMetric(t,!0)}},{key:"counter",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Counter",e,n);var t=new s(e,"counter",r,n,this.config);t.value=Math.abs(parseInt(t.value,10)),this.util.addMetric(t,!0)}},{key:"gauge",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Gauge",e,r,n);var t=new s(e,"gauge",r,n,this.config);this.util.addMetric(t,!0)}},{key:"sendMetric",value:function(e,r,n){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=new s(r,e,n,t,this.config);this.util.addMetric(i,!1)}}]),a}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.statful=t()}(this,function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),i=function(){function e(r){t(this,e),this.debugEnabled=r||!1}return r(e,[{key:"info",value:function(){this.debugEnabled&&console.info.apply(console,Array.prototype.slice.call(arguments))}},{key:"debug",value:function(){this.debugEnabled&&console.debug.apply(console,Array.prototype.slice.call(arguments))}},{key:"error",value:function(){this.debugEnabled&&console.error.apply(console,Array.prototype.slice.call(arguments))}}]),e}(),n=function(){function e(r){t(this,e),this.config={},Object.assign(this.config,r),this.logger=new i(this.config.debug),this.config&&this.config.flushInterval&&this.registerQueue(this.config.flushInterval)}return r(e,[{key:"sendData",value:function(e){var t=this,r=this.config.apiAddress+"/beacon/metrics",i=JSON.stringify(e);if(this.config.dryrun)this.logger.debug("Dryrun data",e);else{var n=new XMLHttpRequest;n.open("POST",r,!0),n.timeout=this.config.timeout,n.setRequestHeader("Content-type","application/json"),n.send(i),n.onreadystatechange=function(){200==n.status||201==n.status?t.logger.debug("Successfully send metric"):t.logger.debug("Error send metric",r,n.status)}}}},{key:"registerQueue",value:function(e){var t=this,r=void 0;return this.metricsQueue=[],"number"==typeof e&&e>0&&(r=setInterval(function(){t.metricsQueue.length>0&&(t.sendData(t.metricsQueue),t.metricsQueue=[])},e),window.addEventListener("beforeunload",function(){clearInterval(r)}),!0)}},{key:"addMetric",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&"function"==typeof e.isValid&&e.isValid()?this.shouldAddMetric(e)?t?this.metricsQueue.push(e):this.sendData([e]):this.logger.debug("Metric was discarded due to sample rate."):this.logger.error("Invalid metric.")}},{key:"shouldAddMetric",value:function(){var e=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).sampleRate||this.config.sampleRate||100)/100;return Math.random()<=e}}]),e}(),a=["avg","count","sum","first","last","p90","p95","min","max"],o=[10,30,60,120,180,300],s=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};t(this,e),this.name=r,this.type=i,this.value=n;var s=[],u=[],g=0;o[i]&&(s=o[i].tags,u=o[i].aggregations,g=o[i].aggregationFrequency),this.tags=this.buildTags(a.tags,o.tags,s,o.app),this.aggregations=this.buildAggregations(a.aggregations,o.aggregations,u),this.aggregationFrequency=this.buildAggregationFrequency(a.aggregationFrequency,o.aggregationFrequency,g),this.namespace=a.namespace||o.namespace,this.sampleRate=a.sampleRate||o.sampleRate}return r(e,[{key:"buildTags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments[3],n={};return Object.assign(n,t),Object.assign(n,r),Object.assign(n,e),!n.app&&i&&(n.app=i),n}},{key:"buildAggregations",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=[];return i=i.concat(t),i=i.concat(r).filter(this.uniq),i=i.concat(e).filter(this.uniq),this.filterAggregations(i)}},{key:"uniq",value:function(e,t,r){return e&&r.indexOf(e)===t}},{key:"buildAggregationFrequency",value:function(e,t,r){var i=e||r||t;return this.filterAggregationFrequency(i)}},{key:"filterAggregations",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return a.includes(e)})}},{key:"filterAggregationFrequency",value:function(e){return o.includes(e)?e:10}},{key:"isValid",value:function(){return!(isNaN(this.value)||!this.name)}}]),e}(),u={dryrun:!1,debug:!1,app:void 0,namespace:"web",tags:{},aggregations:[],aggregationFrequency:10,timer:{tags:{unit:"ms"},aggregations:["avg","p90","count"]},counter:{tags:{},aggregations:["sum","count"]},gauge:{tags:{},aggregations:["last"]},timeout:2e3,flushInterval:1e4,sampleRate:100};return function(){function a(){t(this,a)}return r(a,null,[{key:"initialize",value:function(t){this.config={apiAddress:"https://beacon.statful.com"},"object"===(void 0===t?"undefined":e(t))&&null!==t||(t={}),Object.assign(this.config,u),Object.assign(this.config,t),this.logger=new i(this.config.debug),this.util=new n(this.config)}},{key:"measureTimeUserTiming",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=window.performance.getEntriesByName(e).filter(function(e){return"measure"===e.entryType}),r=void 0;return t.length>0?r=t[t.length-1].duration:this.logger.debug("Measure "+e+" not found"),r}},{key:"clearMarks",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMarks(e)}):window.performance.clearMarks()}catch(e){this.logger.error(e)}}},{key:"clearMeasures",value:function(e){try{Array.isArray(e)?e.forEach(function(e){e&&window.performance.clearMeasures(e)}):window.performance.clearMeasures()}catch(e){this.logger.error(e)}}},{key:"registerMark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{this.logger.debug("Register Mark",e),e?window.performance.mark(e):this.logger.error("Undefined resource name to register as a mark")}catch(e){this.logger.error(e)}}},{key:"registerMeasure",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{if(this.logger.debug("Register Measure",e,t,r),e){var i={clearMarks:!1,clearMeasures:!1};Object.assign(i,r),i.endMark||(this.registerMark(e),i.endMark=e),window.performance.measure(e,i.startMark,i.endMark);var n=this.measureTimeUserTiming(e);if(n){var a=new s(t,"timer",n,i,this.config);this.util.addMetric(a,!0)}else this.logger.error("Failed to get measure time to register as timer value");i.clearMarks&&this.clearMarks([i.startMark,i.endMark]),i.clearMeasures&&this.clearMeasures([e])}else this.logger.error("Undefined resource name to register as a measure")}catch(e){this.logger.error(e)}}},{key:"timer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Timer",e,t,r);var i=new s(e,"timer",t,r,this.config);this.util.addMetric(i,!0)}},{key:"counter",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Counter",e,r);var i=new s(e,"counter",t,r,this.config);i.value=Math.abs(parseInt(i.value,10)),this.util.addMetric(i,!0)}},{key:"gauge",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.logger.debug("Register Gauge",e,t,r);var i=new s(e,"gauge",t,r,this.config);this.util.addMetric(i,!0)}},{key:"sendMetric",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=new s(t,e,r,i,this.config);this.util.addMetric(n,!1)}}]),a}()});
{
"name": "statful-client-javascript",
"version": "2.0.4",
"version": "2.1.0",
"description": "Statful client for Javascript applications",

@@ -25,9 +25,10 @@ "banner": "/**\n* <%= pkg.name %> <%= pkg.version %>\n* Copyright 2017 Statful <https://www.statful.com/>\n*/\n",

"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"eslint": "^4.5.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.11.0",
"jasmine-ajax": "^3.3.1",
"jasmine-core": "^2.7.0",
"karma": "^1.7.0",
"jasmine-core": "^2.8.0",
"karma": "^1.7.1",
"karma-coverage": "^1.1.1",

@@ -40,7 +41,8 @@ "karma-jasmine": "^1.1.0",

"rollup-plugin-istanbul": "^1.1.0",
"rollup-plugin-license": "^0.4.0",
"rollup-plugin-license": "^0.5.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"usertiming": "^0.1.8"
}
},
"dependencies": {}
}

@@ -162,3 +162,3 @@ # statful-client-javascript

```bash
$ npm install
$ yarn install
```

@@ -165,0 +165,0 @@

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

import 'usertiming';
import StatfulLogger from './logger';

@@ -115,13 +114,2 @@ import StatfulUtil from './statful-util';

/**
* Clear resources
*/
static clearResources() {
try {
window.performance.clearResourceTimings();
} catch (ex) {
this.logger.error(ex);
}
}
/**
* Clear measures

@@ -128,0 +116,0 @@ * @param {Array} measures - list of measures to clear (optional)

@@ -15,3 +15,6 @@ import StatfulUtil from '../src/statful-util';

it('should to send POST request', () => {
it('should not send POST request - Dry Run', () => {
statfulUtil = new StatfulUtil({
dryrun: true
});
jasmine.Ajax.install();

@@ -23,2 +26,15 @@

const request = jasmine.Ajax.requests.mostRecent();
expect(request).toEqual(undefined);
jasmine.Ajax.uninstall();
});
it('should send POST request', () => {
jasmine.Ajax.install();
statfulUtil.sendData({
id: 1
});
let request = jasmine.Ajax.requests.mostRecent();

@@ -25,0 +41,0 @@

@@ -189,4 +189,2 @@ import statful from '../src/statful';

statful.registerMark('start_test');
spyOn(window.performance, 'clearMarks');

@@ -196,3 +194,3 @@

expect(window.performance.clearMarks).toHaveBeenCalled();
expect(window.performance.clearMarks).toHaveBeenCalledWith();
});

@@ -203,4 +201,2 @@

statful.registerMark('start_test');
spyOn(window.performance, 'clearMarks');

@@ -220,15 +216,13 @@

expect(window.performance.clearMeasures).toHaveBeenCalled();
expect(window.performance.clearMeasures).toHaveBeenCalledWith();
});
it('should clear performance measures when calling clearMeasures with an Array of measures', () => {
it('should clear performance measures when calling clearMeasures with an Array of marks', () => {
statful.initialize();
statful.registerMeasure('measure', 'metric');
spyOn(window.performance, 'clearMeasures');
spyOn(window.performance, 'clearMarks');
statful.clearMeasures(['start_test']);
statful.clearMarks(['measure']);
expect(window.performance.clearMarks).toHaveBeenCalledWith('measure');
expect(window.performance.clearMeasures).toHaveBeenCalledWith('start_test');
});

@@ -246,2 +240,12 @@

it('should not add a performance mark when calling registerMark', () => {
statful.initialize();
spyOn(window.performance, 'mark');
statful.registerMark();
expect(window.performance.mark).not.toHaveBeenCalled();
});
it('should add a performance measure when calling registerMeasure', () => {

@@ -248,0 +252,0 @@ statful.initialize();

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