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

perfume.js

Package Overview
Dependencies
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfume.js - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

4

angular/package.json
{
"name": "perfume.js/angular",
"version": "4.0.1",
"version": "4.3.0",
"peerDependencies": {
"@angular/common": "^6.0.0",
"@angular/core": "^6.0.0",
"perfume.js": "4.0.0"
"perfume.js": "4.2.0"
},

@@ -9,0 +9,0 @@ "main": "bundles/perfume.js-angular.umd.js",

# Changelog
## 4.2.0 (2019-11-17)
* **feat:** added Resource Timining support
* **feat:** added Data Consumption metric
* **feat:** added Largest Contentful Paint support
* **refactor:** reduced the library from over 4Kb to 1.9Kb gzip
## 3.0.3 (2019-10-17)

@@ -4,0 +11,0 @@

@@ -68,11 +68,11 @@ var Perfume = /** @class */ (function () {

*/
Perfume.prototype.start = function (metricName) {
if (!this.checkMetricName(metricName) || !this.isPerformanceSupported()) {
Perfume.prototype.start = function (markName) {
if (!this.checkMetricName(markName) || !this.isPerformanceSupported()) {
return;
}
if (this.metrics[metricName]) {
if (this.metrics[markName]) {
this.logWarn(this.logPrefixRecording + " started.");
return;
}
this.metrics[metricName] = {
this.metrics[markName] = {
end: 0,

@@ -82,3 +82,3 @@ start: this.wp.now(),

// Creates a timestamp in the browser's performance entry buffer
this.performanceMark(metricName, 'start');
this.performanceMark(markName, 'start');
// Reset hidden value

@@ -90,8 +90,8 @@ this.isHidden = false;

*/
Perfume.prototype.end = function (metricName) {
Perfume.prototype.end = function (markName) {
var _this = this;
if (!this.checkMetricName(metricName) || !this.isPerformanceSupported()) {
if (!this.checkMetricName(markName) || !this.isPerformanceSupported()) {
return;
}
var metric = this.metrics[metricName];
var metric = this.metrics[markName];
if (!metric) {

@@ -103,11 +103,11 @@ this.logWarn(this.logPrefixRecording + " stopped.");

metric.end = this.wp.now();
this.performanceMark(metricName, 'end');
this.performanceMark(markName, 'end');
// Get duration and change it to a two decimal value
var duration = this.performanceMeasure(metricName);
var duration = this.performanceMeasure(markName);
var duration2Decimal = parseFloat(duration.toFixed(2));
delete this.metrics[metricName];
delete this.metrics[markName];
this.pushTask(function () {
// Log to console, delete metric and send to analytics tracker
_this.log({ metricName: metricName, duration: duration2Decimal });
_this.sendTiming({ metricName: metricName, duration: duration2Decimal });
_this.log({ measureName: markName, duration: duration2Decimal });
_this.sendTiming({ measureName: markName, duration: duration2Decimal });
});

@@ -309,3 +309,3 @@ return duration2Decimal;

};
Perfume.prototype.logData = function (metricName, data) {
Perfume.prototype.logData = function (measureName, data) {
var _this = this;

@@ -319,5 +319,5 @@ Object.keys(data).forEach(function (key) {

// Logs the metric in the internal console.log
_this.log({ metricName: metricName, data: data, suffix: '' });
_this.log({ measureName: measureName, data: data, suffix: '' });
// Sends the metric to an external tracking service
_this.sendTiming({ metricName: metricName, data: data });
_this.sendTiming({ measureName: measureName, data: data });
});

@@ -329,3 +329,3 @@ };

*/
Perfume.prototype.logMetric = function (duration, metricName, suffix) {
Perfume.prototype.logMetric = function (duration, measureName, suffix) {
var _this = this;

@@ -341,5 +341,5 @@ if (suffix === void 0) { suffix = 'ms'; }

// Logs the metric in the internal console.log
_this.log({ metricName: metricName, duration: duration2Decimal, suffix: suffix });
_this.log({ measureName: measureName, duration: duration2Decimal, suffix: suffix });
// Sends the metric to an external tracking service
_this.sendTiming({ metricName: metricName, duration: duration2Decimal });
_this.sendTiming({ measureName: measureName, duration: duration2Decimal });
});

@@ -355,3 +355,3 @@ };

}
if (!options.metricName) {
if (!options.measureName) {
this.logWarn(this.logMetricWarn);

@@ -361,3 +361,3 @@ return;

var style = 'color:#ff6d00;font-size:11px;';
var text = "%c " + this.config.logPrefix + " " + options.metricName + " ";
var text = "%c " + this.config.logPrefix + " " + options.measureName + " ";
if (options.duration) {

@@ -445,4 +445,5 @@ var durationMs = options.duration.toFixed(2);

performanceEntry.initiatorType) {
_this.dataConsumption[performanceEntry.initiatorType] +=
performanceEntry.decodedBodySize / 1000;
var bodySize = performanceEntry.decodedBodySize / 1000;
_this.dataConsumption[performanceEntry.initiatorType] += bodySize;
_this.dataConsumption.total += bodySize;
}

@@ -466,3 +467,3 @@ });

Perfume.prototype.sendTiming = function (options) {
var metricName = options.metricName, data = options.data, duration = options.duration;
var measureName = options.measureName, data = options.data, duration = options.duration;
// Doesn't send timing when page is hidden

@@ -473,3 +474,3 @@ if (this.isHidden) {

// Send metric to custom Analytics service
this.config.analyticsTracker({ metricName: metricName, data: data, duration: duration });
this.config.analyticsTracker({ metricName: measureName, data: data, duration: duration });
};

@@ -476,0 +477,0 @@ return Perfume;

@@ -70,11 +70,11 @@ "use strict";

*/
Perfume.prototype.start = function (metricName) {
if (!this.checkMetricName(metricName) || !this.isPerformanceSupported()) {
Perfume.prototype.start = function (markName) {
if (!this.checkMetricName(markName) || !this.isPerformanceSupported()) {
return;
}
if (this.metrics[metricName]) {
if (this.metrics[markName]) {
this.logWarn(this.logPrefixRecording + " started.");
return;
}
this.metrics[metricName] = {
this.metrics[markName] = {
end: 0,

@@ -84,3 +84,3 @@ start: this.wp.now(),

// Creates a timestamp in the browser's performance entry buffer
this.performanceMark(metricName, 'start');
this.performanceMark(markName, 'start');
// Reset hidden value

@@ -92,8 +92,8 @@ this.isHidden = false;

*/
Perfume.prototype.end = function (metricName) {
Perfume.prototype.end = function (markName) {
var _this = this;
if (!this.checkMetricName(metricName) || !this.isPerformanceSupported()) {
if (!this.checkMetricName(markName) || !this.isPerformanceSupported()) {
return;
}
var metric = this.metrics[metricName];
var metric = this.metrics[markName];
if (!metric) {

@@ -105,11 +105,11 @@ this.logWarn(this.logPrefixRecording + " stopped.");

metric.end = this.wp.now();
this.performanceMark(metricName, 'end');
this.performanceMark(markName, 'end');
// Get duration and change it to a two decimal value
var duration = this.performanceMeasure(metricName);
var duration = this.performanceMeasure(markName);
var duration2Decimal = parseFloat(duration.toFixed(2));
delete this.metrics[metricName];
delete this.metrics[markName];
this.pushTask(function () {
// Log to console, delete metric and send to analytics tracker
_this.log({ metricName: metricName, duration: duration2Decimal });
_this.sendTiming({ metricName: metricName, duration: duration2Decimal });
_this.log({ measureName: markName, duration: duration2Decimal });
_this.sendTiming({ measureName: markName, duration: duration2Decimal });
});

@@ -311,3 +311,3 @@ return duration2Decimal;

};
Perfume.prototype.logData = function (metricName, data) {
Perfume.prototype.logData = function (measureName, data) {
var _this = this;

@@ -321,5 +321,5 @@ Object.keys(data).forEach(function (key) {

// Logs the metric in the internal console.log
_this.log({ metricName: metricName, data: data, suffix: '' });
_this.log({ measureName: measureName, data: data, suffix: '' });
// Sends the metric to an external tracking service
_this.sendTiming({ metricName: metricName, data: data });
_this.sendTiming({ measureName: measureName, data: data });
});

@@ -331,3 +331,3 @@ };

*/
Perfume.prototype.logMetric = function (duration, metricName, suffix) {
Perfume.prototype.logMetric = function (duration, measureName, suffix) {
var _this = this;

@@ -343,5 +343,5 @@ if (suffix === void 0) { suffix = 'ms'; }

// Logs the metric in the internal console.log
_this.log({ metricName: metricName, duration: duration2Decimal, suffix: suffix });
_this.log({ measureName: measureName, duration: duration2Decimal, suffix: suffix });
// Sends the metric to an external tracking service
_this.sendTiming({ metricName: metricName, duration: duration2Decimal });
_this.sendTiming({ measureName: measureName, duration: duration2Decimal });
});

@@ -357,3 +357,3 @@ };

}
if (!options.metricName) {
if (!options.measureName) {
this.logWarn(this.logMetricWarn);

@@ -363,3 +363,3 @@ return;

var style = 'color:#ff6d00;font-size:11px;';
var text = "%c " + this.config.logPrefix + " " + options.metricName + " ";
var text = "%c " + this.config.logPrefix + " " + options.measureName + " ";
if (options.duration) {

@@ -447,4 +447,5 @@ var durationMs = options.duration.toFixed(2);

performanceEntry.initiatorType) {
_this.dataConsumption[performanceEntry.initiatorType] +=
performanceEntry.decodedBodySize / 1000;
var bodySize = performanceEntry.decodedBodySize / 1000;
_this.dataConsumption[performanceEntry.initiatorType] += bodySize;
_this.dataConsumption.total += bodySize;
}

@@ -468,3 +469,3 @@ });

Perfume.prototype.sendTiming = function (options) {
var metricName = options.metricName, data = options.data, duration = options.duration;
var measureName = options.measureName, data = options.data, duration = options.duration;
// Doesn't send timing when page is hidden

@@ -475,3 +476,3 @@ if (this.isHidden) {

// Send metric to custom Analytics service
this.config.analyticsTracker({ metricName: metricName, data: data, duration: duration });
this.config.analyticsTracker({ metricName: measureName, data: data, duration: duration });
};

@@ -478,0 +479,0 @@ return Perfume;

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

var t=function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var s=this.o[t];if(s){s.end=this.l.now(),this._(t,"end");var n=this.D(t),e=parseFloat(n.toFixed(2));return delete this.o[t],this.I((function(){i.log({metricName:t,duration:e}),i.L({metricName:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(s){setTimeout((function(){var n=i.end(t);s(n)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.O=function(t){this.j({q:t,metricName:"firstInputDelay",M:"duration"}),this.B(),this.R()},t.prototype.R=function(){this.S&&(clearTimeout(this.S),this.S=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.B=function(){this.m.A&&this.i&&(this.G(this.i,"largestContentfulPaint"),this.m.A.disconnect())},t.prototype.H=function(){try{this.m.J=this.K("first-input",this.O.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.U=function(){var t=this;try{this.m.V=this.K("paint",(function(i){t.j({q:i,W:"first-paint",metricName:"firstPaint",M:"startTime"}),t.j({q:i,W:"first-contentful-paint",metricName:"firstContentfulPaint",M:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.X=function(){var t=this;try{this.m.A=this.K("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.i=s.renderTime||s.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.U(),this.H(),this.X(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Y()},t.prototype.Y=function(){var t=this;try{this.K("resource",(function(i){t.Z({q:i})}))}catch(t){this.F("DataConsumption:failed")}this.S=setTimeout((function(){t.R()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.$=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,s=t.responseEnd;return this.u={fetchTime:s-t.fetchStart,workerTime:t.tt>0?s-t.tt:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.it-t.st||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){s.log({metricName:t,data:i,suffix:""}),s.L({metricName:t,data:i})}))},t.prototype.G=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){n.log({metricName:i,duration:e,suffix:s}),n.L({metricName:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.metricName){var i="color:#ff6d00;font-size:11px;",s="%c "+this.config.logPrefix+" "+t.metricName+" ";if(t.duration)s+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(s,i);else t.data&&this.c.log(s,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var s="mark_"+t+"_"+i;this.l.mark(s)},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.$(t)},t.prototype.K=function(t,i){return this.nt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.nt.observe({type:t,buffered:!0}),this.nt},t.prototype.j=function(t){var i=this;t.q.forEach((function(s){i.config[t.metricName]&&(!t.W||t.W&&s.name===t.W)&&i.G(s[t.M],t.metricName),i.m.V&&"first-contentful-paint"===s.name&&i.m.V.disconnect()})),this.m.J&&"firstInputDelay"===t.metricName&&this.m.J.disconnect()},t.prototype.Z=function(t){var i=this;t.q.forEach((function(t){i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType&&(i.dataConsumption[t.initiatorType]+=t.decodedBodySize/1e3)}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.L=function(t){var i=t.metricName,s=t.data,n=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:s,duration:n})},t}();export default t;
var t=function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var s=this.o[t];if(s){s.end=this.l.now(),this._(t,"end");var n=this.D(t),e=parseFloat(n.toFixed(2));return delete this.o[t],this.I((function(){i.log({L:t,duration:e}),i.O({L:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(s){setTimeout((function(){var n=i.end(t);s(n)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.j=function(t){this.q({M:t,metricName:"firstInputDelay",B:"duration"}),this.R(),this.S()},t.prototype.S=function(){this.A&&(clearTimeout(this.A),this.A=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.R=function(){this.m.G&&this.i&&(this.H(this.i,"largestContentfulPaint"),this.m.G.disconnect())},t.prototype.J=function(){try{this.m.K=this.U("first-input",this.j.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.V=function(){var t=this;try{this.m.W=this.U("paint",(function(i){t.q({M:i,X:"first-paint",metricName:"firstPaint",B:"startTime"}),t.q({M:i,X:"first-contentful-paint",metricName:"firstContentfulPaint",B:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.Y=function(){var t=this;try{this.m.G=this.U("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.i=s.renderTime||s.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.V(),this.J(),this.Y(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Z()},t.prototype.Z=function(){var t=this;try{this.U("resource",(function(i){t.$({M:i})}))}catch(t){this.F("DataConsumption:failed")}this.A=setTimeout((function(){t.S()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.tt=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,s=t.responseEnd;return this.u={fetchTime:s-t.fetchStart,workerTime:t.it>0?s-t.it:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.st-t.nt||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){s.log({L:t,data:i,suffix:""}),s.O({L:t,data:i})}))},t.prototype.H=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){n.log({L:i,duration:e,suffix:s}),n.O({L:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.L){var i="color:#ff6d00;font-size:11px;",s="%c "+this.config.logPrefix+" "+t.L+" ";if(t.duration)s+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(s,i);else t.data&&this.c.log(s,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var s="mark_"+t+"_"+i;this.l.mark(s)},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.tt(t)},t.prototype.U=function(t,i){return this.et=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.et.observe({type:t,buffered:!0}),this.et},t.prototype.q=function(t){var i=this;t.M.forEach((function(s){i.config[t.metricName]&&(!t.X||t.X&&s.name===t.X)&&i.H(s[t.B],t.metricName),i.m.W&&"first-contentful-paint"===s.name&&i.m.W.disconnect()})),this.m.K&&"firstInputDelay"===t.metricName&&this.m.K.disconnect()},t.prototype.$=function(t){var i=this;t.M.forEach((function(t){if(i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.dataConsumption[t.initiatorType]+=s,i.dataConsumption.total+=s}}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.O=function(t){var i=t.L,s=t.data,n=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:s,duration:n})},t}();export default t;
//# sourceMappingURL=perfume.esm.min.js.map

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

var Perfume=function(){"use strict";return function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var n=this.o[t];if(n){n.end=this.l.now(),this._(t,"end");var s=this.D(t),e=parseFloat(s.toFixed(2));return delete this.o[t],this.I((function(){i.log({metricName:t,duration:e}),i.L({metricName:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(n){setTimeout((function(){var s=i.end(t);n(s)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.O=function(t){this.j({q:t,metricName:"firstInputDelay",M:"duration"}),this.B(),this.R()},t.prototype.R=function(){this.S&&(clearTimeout(this.S),this.S=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.B=function(){this.m.A&&this.i&&(this.G(this.i,"largestContentfulPaint"),this.m.A.disconnect())},t.prototype.H=function(){try{this.m.J=this.K("first-input",this.O.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.U=function(){var t=this;try{this.m.V=this.K("paint",(function(i){t.j({q:i,W:"first-paint",metricName:"firstPaint",M:"startTime"}),t.j({q:i,W:"first-contentful-paint",metricName:"firstContentfulPaint",M:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.X=function(){var t=this;try{this.m.A=this.K("largest-contentful-paint",(function(i){var n=i.pop();n&&(t.i=n.renderTime||n.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.U(),this.H(),this.X(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Y()},t.prototype.Y=function(){var t=this;try{this.K("resource",(function(i){t.Z({q:i})}))}catch(t){this.F("DataConsumption:failed")}this.S=setTimeout((function(){t.R()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.$=function(t){var i=this.l.getEntriesByName(t),n=i[i.length-1];return n&&"measure"===n.entryType?n.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,n=t.responseEnd;return this.u={fetchTime:n-t.fetchStart,workerTime:t.tt>0?n-t.tt:0,totalTime:n-t.requestStart,downloadTime:n-i,timeToFirstByte:i-t.requestStart,headerSize:t.it-t.nt||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var n=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){n.log({metricName:t,data:i,suffix:""}),n.L({metricName:t,data:i})}))},t.prototype.G=function(t,i,n){var s=this;void 0===n&&(n="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){s.log({metricName:i,duration:e,suffix:n}),s.L({metricName:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.metricName){var i="color:#ff6d00;font-size:11px;",n="%c "+this.config.logPrefix+" "+t.metricName+" ";if(t.duration)n+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(n,i);else t.data&&this.c.log(n,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var n="mark_"+t+"_"+i;this.l.mark(n)},t.prototype.D=function(t){var i="mark_"+t+"_start",n="mark_"+t+"_end";return this.l.measure(t,i,n),this.$(t)},t.prototype.K=function(t,i){return this.st=new PerformanceObserver((function(t){var n=t.getEntries();i(n)})),this.st.observe({type:t,buffered:!0}),this.st},t.prototype.j=function(t){var i=this;t.q.forEach((function(n){i.config[t.metricName]&&(!t.W||t.W&&n.name===t.W)&&i.G(n[t.M],t.metricName),i.m.V&&"first-contentful-paint"===n.name&&i.m.V.disconnect()})),this.m.J&&"firstInputDelay"===t.metricName&&this.m.J.disconnect()},t.prototype.Z=function(t){var i=this;t.q.forEach((function(t){i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType&&(i.dataConsumption[t.initiatorType]+=t.decodedBodySize/1e3)}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.L=function(t){var i=t.metricName,n=t.data,s=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:n,duration:s})},t}()}();
var Perfume=function(){"use strict";return function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var s=this.o[t];if(s){s.end=this.l.now(),this._(t,"end");var n=this.D(t),e=parseFloat(n.toFixed(2));return delete this.o[t],this.I((function(){i.log({L:t,duration:e}),i.O({L:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(s){setTimeout((function(){var n=i.end(t);s(n)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.j=function(t){this.q({M:t,metricName:"firstInputDelay",B:"duration"}),this.R(),this.S()},t.prototype.S=function(){this.A&&(clearTimeout(this.A),this.A=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.R=function(){this.m.G&&this.i&&(this.H(this.i,"largestContentfulPaint"),this.m.G.disconnect())},t.prototype.J=function(){try{this.m.K=this.U("first-input",this.j.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.V=function(){var t=this;try{this.m.W=this.U("paint",(function(i){t.q({M:i,X:"first-paint",metricName:"firstPaint",B:"startTime"}),t.q({M:i,X:"first-contentful-paint",metricName:"firstContentfulPaint",B:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.Y=function(){var t=this;try{this.m.G=this.U("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.i=s.renderTime||s.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.V(),this.J(),this.Y(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Z()},t.prototype.Z=function(){var t=this;try{this.U("resource",(function(i){t.$({M:i})}))}catch(t){this.F("DataConsumption:failed")}this.A=setTimeout((function(){t.S()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.tt=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,s=t.responseEnd;return this.u={fetchTime:s-t.fetchStart,workerTime:t.it>0?s-t.it:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.st-t.nt||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){s.log({L:t,data:i,suffix:""}),s.O({L:t,data:i})}))},t.prototype.H=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){n.log({L:i,duration:e,suffix:s}),n.O({L:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.L){var i="color:#ff6d00;font-size:11px;",s="%c "+this.config.logPrefix+" "+t.L+" ";if(t.duration)s+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(s,i);else t.data&&this.c.log(s,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var s="mark_"+t+"_"+i;this.l.mark(s)},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.tt(t)},t.prototype.U=function(t,i){return this.et=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.et.observe({type:t,buffered:!0}),this.et},t.prototype.q=function(t){var i=this;t.M.forEach((function(s){i.config[t.metricName]&&(!t.X||t.X&&s.name===t.X)&&i.H(s[t.B],t.metricName),i.m.W&&"first-contentful-paint"===s.name&&i.m.W.disconnect()})),this.m.K&&"firstInputDelay"===t.metricName&&this.m.K.disconnect()},t.prototype.$=function(t){var i=this;t.M.forEach((function(t){if(i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.dataConsumption[t.initiatorType]+=s,i.dataConsumption.total+=s}}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.O=function(t){var i=t.L,s=t.data,n=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:s,duration:n})},t}()}();
//# sourceMappingURL=perfume.iife.min.js.map

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

"use strict";var Perfume=function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var s=this.o[t];if(s){s.end=this.l.now(),this._(t,"end");var n=this.D(t),e=parseFloat(n.toFixed(2));return delete this.o[t],this.I((function(){i.log({metricName:t,duration:e}),i.L({metricName:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(s){setTimeout((function(){var n=i.end(t);s(n)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.O=function(t){this.j({q:t,metricName:"firstInputDelay",M:"duration"}),this.B(),this.R()},t.prototype.R=function(){this.S&&(clearTimeout(this.S),this.S=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.B=function(){this.m.A&&this.i&&(this.G(this.i,"largestContentfulPaint"),this.m.A.disconnect())},t.prototype.H=function(){try{this.m.J=this.K("first-input",this.O.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.U=function(){var t=this;try{this.m.V=this.K("paint",(function(i){t.j({q:i,W:"first-paint",metricName:"firstPaint",M:"startTime"}),t.j({q:i,W:"first-contentful-paint",metricName:"firstContentfulPaint",M:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.X=function(){var t=this;try{this.m.A=this.K("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.i=s.renderTime||s.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.U(),this.H(),this.X(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Y()},t.prototype.Y=function(){var t=this;try{this.K("resource",(function(i){t.Z({q:i})}))}catch(t){this.F("DataConsumption:failed")}this.S=setTimeout((function(){t.R()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.$=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,s=t.responseEnd;return this.u={fetchTime:s-t.fetchStart,workerTime:t.tt>0?s-t.tt:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.it-t.st||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){s.log({metricName:t,data:i,suffix:""}),s.L({metricName:t,data:i})}))},t.prototype.G=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){n.log({metricName:i,duration:e,suffix:s}),n.L({metricName:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.metricName){var i="color:#ff6d00;font-size:11px;",s="%c "+this.config.logPrefix+" "+t.metricName+" ";if(t.duration)s+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(s,i);else t.data&&this.c.log(s,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var s="mark_"+t+"_"+i;this.l.mark(s)},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.$(t)},t.prototype.K=function(t,i){return this.nt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.nt.observe({type:t,buffered:!0}),this.nt},t.prototype.j=function(t){var i=this;t.q.forEach((function(s){i.config[t.metricName]&&(!t.W||t.W&&s.name===t.W)&&i.G(s[t.M],t.metricName),i.m.V&&"first-contentful-paint"===s.name&&i.m.V.disconnect()})),this.m.J&&"firstInputDelay"===t.metricName&&this.m.J.disconnect()},t.prototype.Z=function(t){var i=this;t.q.forEach((function(t){i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType&&(i.dataConsumption[t.initiatorType]+=t.decodedBodySize/1e3)}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.L=function(t){var i=t.metricName,s=t.data,n=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:s,duration:n})},t}();module.exports=Perfume;
"use strict";var Perfume=function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.t=!1,this.i=0,this.s="Missing metric name",this.h="Recording already",this.o={},this.u={},this.m={},this.w=window,this.l=window.performance,this.v=function(){i.d.hidden&&(i.t=i.d.hidden)},this.config=Object.assign({},this.config,t),this.p()&&(this.g()&&this.T(),this.P(),this.config.navigationTiming&&this.N("navigationTiming",this.C()))}return t.prototype.start=function(t){this.k(t)&&this.p()&&(this.o[t]?this.F(this.h+" started."):(this.o[t]={end:0,start:this.l.now()},this._(t,"start"),this.t=!1))},t.prototype.end=function(t){var i=this;if(this.k(t)&&this.p()){var s=this.o[t];if(s){s.end=this.l.now(),this._(t,"end");var n=this.D(t),e=parseFloat(n.toFixed(2));return delete this.o[t],this.I((function(){i.log({L:t,duration:e}),i.O({L:t,duration:e})})),e}this.F(this.h+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(s){setTimeout((function(){var n=i.end(t);s(n)}))}))},t.prototype.k=function(t){return!!t||(this.F(this.s),!1)},t.prototype.j=function(t){this.q({M:t,metricName:"firstInputDelay",B:"duration"}),this.R(),this.S()},t.prototype.S=function(){this.A&&(clearTimeout(this.A),this.A=void 0,this.N("dataConsumption",this.dataConsumption))},t.prototype.R=function(){this.m.G&&this.i&&(this.H(this.i,"largestContentfulPaint"),this.m.G.disconnect())},t.prototype.J=function(){try{this.m.K=this.U("first-input",this.j.bind(this))}catch(t){this.F("FID:failed")}},t.prototype.V=function(){var t=this;try{this.m.W=this.U("paint",(function(i){t.q({M:i,X:"first-paint",metricName:"firstPaint",B:"startTime"}),t.q({M:i,X:"first-contentful-paint",metricName:"firstContentfulPaint",B:"startTime"})}))}catch(t){this.F("FP:failed")}},t.prototype.Y=function(){var t=this;try{this.m.G=this.U("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.i=s.renderTime||s.loadTime)}))}catch(t){this.F("LCP:failed")}},t.prototype.T=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.V(),this.J(),this.Y(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Z()},t.prototype.Z=function(){var t=this;try{this.U("resource",(function(i){t.$({M:i})}))}catch(t){this.F("DataConsumption:failed")}this.A=setTimeout((function(){t.S()}),15e3)},t.prototype.p=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.g=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.tt=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.C=function(){if(!this.config.navigationTiming)return{};if(!this.p()||Object.keys(this.u).length)return this.u;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.u;var i=t.responseStart,s=t.responseEnd;return this.u={fetchTime:s-t.fetchStart,workerTime:t.it>0?s-t.it:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.st-t.nt||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.u},t.prototype.N=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){s.log({L:t,data:i,suffix:""}),s.O({L:t,data:i})}))},t.prototype.H=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){n.log({L:i,duration:e,suffix:s}),n.O({L:i,duration:e})}))},t.prototype.log=function(t){if(!this.t&&this.config.logging)if(t.L){var i="color:#ff6d00;font-size:11px;",s="%c "+this.config.logPrefix+" "+t.L+" ";if(t.duration)s+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(s,i);else t.data&&this.c.log(s,i,t.data)}else this.F(this.s)},t.prototype.F=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.v)},t.prototype._=function(t,i){var s="mark_"+t+"_"+i;this.l.mark(s)},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.tt(t)},t.prototype.U=function(t,i){return this.et=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.et.observe({type:t,buffered:!0}),this.et},t.prototype.q=function(t){var i=this;t.M.forEach((function(s){i.config[t.metricName]&&(!t.X||t.X&&s.name===t.X)&&i.H(s[t.B],t.metricName),i.m.W&&"first-contentful-paint"===s.name&&i.m.W.disconnect()})),this.m.K&&"firstInputDelay"===t.metricName&&this.m.K.disconnect()},t.prototype.$=function(t){var i=this;t.M.forEach((function(t){if(i.config.resourceTiming&&i.N("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.dataConsumption[t.initiatorType]+=s,i.dataConsumption.total+=s}}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.O=function(t){var i=t.L,s=t.data,n=t.duration;this.t||this.config.analyticsTracker({metricName:i,data:s,duration:n})},t}();module.exports=Perfume;
//# sourceMappingURL=perfume.min.js.map

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

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).t=i()}(this,(function(){"use strict";return function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.i=!1,this.s=0,this.h="Missing metric name",this.o="Recording already",this.u={},this.m={},this.l={},this.w=window,this.v=window.performance,this.p=function(){i.d.hidden&&(i.i=i.d.hidden)},this.config=Object.assign({},this.config,t),this.g()&&(this.T()&&this.P(),this.N(),this.config.navigationTiming&&this.C("navigationTiming",this.k()))}return t.prototype.start=function(t){this.F(t)&&this.g()&&(this.u[t]?this._(this.o+" started."):(this.u[t]={end:0,start:this.v.now()},this.j(t,"start"),this.i=!1))},t.prototype.end=function(t){var i=this;if(this.F(t)&&this.g()){var n=this.u[t];if(n){n.end=this.v.now(),this.j(t,"end");var s=this.D(t),e=parseFloat(s.toFixed(2));return delete this.u[t],this.I((function(){i.log({metricName:t,duration:e}),i.L({metricName:t,duration:e})})),e}this._(this.o+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(n){setTimeout((function(){var s=i.end(t);n(s)}))}))},t.prototype.F=function(t){return!!t||(this._(this.h),!1)},t.prototype.O=function(t){this.q({M:t,metricName:"firstInputDelay",B:"duration"}),this.R(),this.S()},t.prototype.S=function(){this.A&&(clearTimeout(this.A),this.A=void 0,this.C("dataConsumption",this.dataConsumption))},t.prototype.R=function(){this.l.G&&this.s&&(this.H(this.s,"largestContentfulPaint"),this.l.G.disconnect())},t.prototype.J=function(){try{this.l.K=this.U("first-input",this.O.bind(this))}catch(t){this._("FID:failed")}},t.prototype.V=function(){var t=this;try{this.l.W=this.U("paint",(function(i){t.q({M:i,X:"first-paint",metricName:"firstPaint",B:"startTime"}),t.q({M:i,X:"first-contentful-paint",metricName:"firstContentfulPaint",B:"startTime"})}))}catch(t){this._("FP:failed")}},t.prototype.Y=function(){var t=this;try{this.l.G=this.U("largest-contentful-paint",(function(i){var n=i.pop();n&&(t.s=n.renderTime||n.loadTime)}))}catch(t){this._("LCP:failed")}},t.prototype.P=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.V(),this.J(),this.Y(),(this.config.resourceTiming||this.config.dataConsumption)&&this.Z()},t.prototype.Z=function(){var t=this;try{this.U("resource",(function(i){t.$({M:i})}))}catch(t){this._("DataConsumption:failed")}this.A=setTimeout((function(){t.S()}),15e3)},t.prototype.g=function(){return this.v&&!!this.v.getEntriesByType&&!!this.v.now&&!!this.v.mark},t.prototype.T=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.tt=function(t){var i=this.v.getEntriesByName(t),n=i[i.length-1];return n&&"measure"===n.entryType?n.duration:-1},t.prototype.k=function(){if(!this.config.navigationTiming)return{};if(!this.g()||Object.keys(this.m).length)return this.m;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.m;var i=t.responseStart,n=t.responseEnd;return this.m={fetchTime:n-t.fetchStart,workerTime:t.it>0?n-t.it:0,totalTime:n-t.requestStart,downloadTime:n-i,timeToFirstByte:i-t.requestStart,headerSize:t.nt-t.st||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.m},t.prototype.C=function(t,i){var n=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){n.log({metricName:t,data:i,suffix:""}),n.L({metricName:t,data:i})}))},t.prototype.H=function(t,i,n){var s=this;void 0===n&&(n="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){s.log({metricName:i,duration:e,suffix:n}),s.L({metricName:i,duration:e})}))},t.prototype.log=function(t){if(!this.i&&this.config.logging)if(t.metricName){var i="color:#ff6d00;font-size:11px;",n="%c "+this.config.logPrefix+" "+t.metricName+" ";if(t.duration)n+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(n,i);else t.data&&this.c.log(n,i,t.data)}else this._(this.h)},t.prototype._=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.N=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.p)},t.prototype.j=function(t,i){var n="mark_"+t+"_"+i;this.v.mark(n)},t.prototype.D=function(t){var i="mark_"+t+"_start",n="mark_"+t+"_end";return this.v.measure(t,i,n),this.tt(t)},t.prototype.U=function(t,i){return this.et=new PerformanceObserver((function(t){var n=t.getEntries();i(n)})),this.et.observe({type:t,buffered:!0}),this.et},t.prototype.q=function(t){var i=this;t.M.forEach((function(n){i.config[t.metricName]&&(!t.X||t.X&&n.name===t.X)&&i.H(n[t.B],t.metricName),i.l.W&&"first-contentful-paint"===n.name&&i.l.W.disconnect()})),this.l.K&&"firstInputDelay"===t.metricName&&this.l.K.disconnect()},t.prototype.$=function(t){var i=this;t.M.forEach((function(t){i.config.resourceTiming&&i.C("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType&&(i.dataConsumption[t.initiatorType]+=t.decodedBodySize/1e3)}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.L=function(t){var i=t.metricName,n=t.data,s=t.duration;this.i||this.config.analyticsTracker({metricName:i,data:n,duration:s})},t}()}));
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).t=i()}(this,(function(){"use strict";return function(){function t(t){var i=this;void 0===t&&(t={}),this.config={firstContentfulPaint:!1,firstPaint:!1,firstInputDelay:!1,dataConsumption:!1,largestContentfulPaint:!1,navigationTiming:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3,warning:!1},this.c=window.console,this.d=document,this.dataConsumption={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.i=!1,this.s=0,this.h="Missing metric name",this.o="Recording already",this.u={},this.m={},this.l={},this.w=window,this.v=window.performance,this.p=function(){i.d.hidden&&(i.i=i.d.hidden)},this.config=Object.assign({},this.config,t),this.g()&&(this.T()&&this.P(),this.N(),this.config.navigationTiming&&this.C("navigationTiming",this.k()))}return t.prototype.start=function(t){this.F(t)&&this.g()&&(this.u[t]?this._(this.o+" started."):(this.u[t]={end:0,start:this.v.now()},this.j(t,"start"),this.i=!1))},t.prototype.end=function(t){var i=this;if(this.F(t)&&this.g()){var n=this.u[t];if(n){n.end=this.v.now(),this.j(t,"end");var s=this.D(t),e=parseFloat(s.toFixed(2));return delete this.u[t],this.I((function(){i.log({L:t,duration:e}),i.O({L:t,duration:e})})),e}this._(this.o+" stopped.")}},t.prototype.endPaint=function(t){var i=this;return new Promise((function(n){setTimeout((function(){var s=i.end(t);n(s)}))}))},t.prototype.F=function(t){return!!t||(this._(this.h),!1)},t.prototype.q=function(t){this.M({B:t,metricName:"firstInputDelay",R:"duration"}),this.S(),this.A()},t.prototype.A=function(){this.G&&(clearTimeout(this.G),this.G=void 0,this.C("dataConsumption",this.dataConsumption))},t.prototype.S=function(){this.l.H&&this.s&&(this.J(this.s,"largestContentfulPaint"),this.l.H.disconnect())},t.prototype.K=function(){try{this.l.U=this.V("first-input",this.q.bind(this))}catch(t){this._("FID:failed")}},t.prototype.W=function(){var t=this;try{this.l.X=this.V("paint",(function(i){t.M({B:i,Y:"first-paint",metricName:"firstPaint",R:"startTime"}),t.M({B:i,Y:"first-contentful-paint",metricName:"firstContentfulPaint",R:"startTime"})}))}catch(t){this._("FP:failed")}},t.prototype.Z=function(){var t=this;try{this.l.H=this.V("largest-contentful-paint",(function(i){var n=i.pop();n&&(t.s=n.renderTime||n.loadTime)}))}catch(t){this._("LCP:failed")}},t.prototype.P=function(){(this.config.firstPaint||this.config.firstContentfulPaint)&&this.W(),this.K(),this.Z(),(this.config.resourceTiming||this.config.dataConsumption)&&this.$()},t.prototype.$=function(){var t=this;try{this.V("resource",(function(i){t.tt({B:i})}))}catch(t){this._("DataConsumption:failed")}this.G=setTimeout((function(){t.A()}),15e3)},t.prototype.g=function(){return this.v&&!!this.v.getEntriesByType&&!!this.v.now&&!!this.v.mark},t.prototype.T=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.it=function(t){var i=this.v.getEntriesByName(t),n=i[i.length-1];return n&&"measure"===n.entryType?n.duration:-1},t.prototype.k=function(){if(!this.config.navigationTiming)return{};if(!this.g()||Object.keys(this.m).length)return this.m;var t=performance.getEntriesByType("navigation")[0];if(!t)return this.m;var i=t.responseStart,n=t.responseEnd;return this.m={fetchTime:n-t.fetchStart,workerTime:t.nt>0?n-t.nt:0,totalTime:n-t.requestStart,downloadTime:n-i,timeToFirstByte:i-t.requestStart,headerSize:t.st-t.et||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart},this.m},t.prototype.C=function(t,i){var n=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))})),this.I((function(){n.log({L:t,data:i,suffix:""}),n.O({L:t,data:i})}))},t.prototype.J=function(t,i,n){var s=this;void 0===n&&(n="ms");var e=parseFloat(t.toFixed(2));e>this.config.maxMeasureTime||e<=0||this.I((function(){s.log({L:i,duration:e,suffix:n}),s.O({L:i,duration:e})}))},t.prototype.log=function(t){if(!this.i&&this.config.logging)if(t.L){var i="color:#ff6d00;font-size:11px;",n="%c "+this.config.logPrefix+" "+t.L+" ";if(t.duration)n+=t.duration.toFixed(2)+" "+(t.suffix||"ms"),this.c.log(n,i);else t.data&&this.c.log(n,i,t.data)}else this._(this.h)},t.prototype._=function(t){this.config.warning&&this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.N=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.p)},t.prototype.j=function(t,i){var n="mark_"+t+"_"+i;this.v.mark(n)},t.prototype.D=function(t){var i="mark_"+t+"_start",n="mark_"+t+"_end";return this.v.measure(t,i,n),this.it(t)},t.prototype.V=function(t,i){return this.rt=new PerformanceObserver((function(t){var n=t.getEntries();i(n)})),this.rt.observe({type:t,buffered:!0}),this.rt},t.prototype.M=function(t){var i=this;t.B.forEach((function(n){i.config[t.metricName]&&(!t.Y||t.Y&&n.name===t.Y)&&i.J(n[t.R],t.metricName),i.l.X&&"first-contentful-paint"===n.name&&i.l.X.disconnect()})),this.l.U&&"firstInputDelay"===t.metricName&&this.l.U.disconnect()},t.prototype.tt=function(t){var i=this;t.B.forEach((function(t){if(i.config.resourceTiming&&i.C("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var n=t.decodedBodySize/1e3;i.dataConsumption[t.initiatorType]+=n,i.dataConsumption.total+=n}}))},t.prototype.I=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.O=function(t){var i=t.L,n=t.data,s=t.duration;this.i||this.config.analyticsTracker({metricName:i,data:n,duration:s})},t}()}));
//# sourceMappingURL=perfume.umd.min.js.map
/*!
* Perfume.js v4.2.0 (http://zizzamia.github.io/perfume)
* Perfume.js v4.3.0 (http://zizzamia.github.io/perfume)
* Copyright 2018 The Perfume Authors (https://github.com/Zizzamia/perfume.js/graphs/contributors)

@@ -41,3 +41,3 @@ * Licensed under MIT (https://github.com/Zizzamia/perfume.js/blob/master/LICENSE)

export interface ILogOptions {
metricName: string;
measureName: string;
duration?: number;

@@ -58,3 +58,3 @@ data?: any;

export interface ISendTimingOptions {
metricName: string;
measureName: string;
data?: any;

@@ -125,7 +125,7 @@ duration?: number;

*/
start(metricName: string): void;
start(markName: string): void;
/**
* End performance measurement
*/
end(metricName: string): void | number;
end(markName: string): void | number;
/**

@@ -132,0 +132,0 @@ * End performance measurement after first paint from the beging of it

{
"name": "perfume.js",
"version": "4.2.0",
"version": "4.3.0",
"description": "JavaScript library that measures Navigation Timing, First (Contentful) Paint (FP/FCP), First Input Delay (FID) and components lifecycle performance. Report real user measurements to your favorite analytics tool.",

@@ -83,5 +83,5 @@ "keywords": [

"branches": 90,
"functions": 92,
"lines": 92,
"statements": 92
"functions": 100,
"lines": 96,
"statements": 96
}

@@ -88,0 +88,0 @@ },

@@ -5,7 +5,7 @@ <a href="http://www.perfumejs.com/">

# [Perfume.js v4.2.0](http://perfumejs.com)
# [Perfume.js v4.3.0](http://perfumejs.com)
[![NPM version](https://badge.fury.io/js/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Build Status](https://travis-ci.org/Zizzamia/perfume.js.svg?branch=master)](https://travis-ci.org/Zizzamia/perfume.js) [![NPM Downloads](http://img.shields.io/npm/dm/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Test Coverage](https://api.codeclimate.com/v1/badges/f813d2f45b274d93b8c5/test_coverage)](https://codeclimate.com/github/Zizzamia/perfume.js/test_coverage) [![JS gzip size](https://img.badgesize.io/https://unpkg.com/perfume.js?compression=gzip&label=JS+gzip+size)](https://unpkg.com/perfume.js)
> A flexible library for measuring <b>Navigation Timing</b>, <b>First Contentful Paint</b> (<a href="https://medium.com/@zizzamia/first-contentful-paint-with-a-touch-of-perfume-js-cd11dfd2e18f" target="_blank">FP/FCP</a>), <b>Largest Contentful Paint</b> (LCP), <b>First Input Delay</b> (FID) and components lifecycle performance. Report real user measurements to your favorite analytics tool.
> A flexible library for measuring <b>Navigation Timing</b>, <b>Navigation Timing</b>, <b>First Contentful Paint</b> (<a href="https://medium.com/@zizzamia/first-contentful-paint-with-a-touch-of-perfume-js-cd11dfd2e18f" target="_blank">FP/FCP</a>), <b>Largest Contentful Paint</b> (LCP), <b>First Input Delay</b> (FID) and report real user measurements to your favorite analytics tool.

@@ -21,3 +21,3 @@ <br />

- 🚿 Filters out false positive/negative results
- 🤙 Only 2.1Kb gzip
- 🤙 Only 1.9Kb gzip
- 🛰 Flexible analytics tool

@@ -32,2 +32,3 @@ - ⚡️ Waste-zero ms with [requestIdleCallback](https://developers.google.com/web/updates/2015/08/using-requestidlecallback) strategy built-in

* Navigation Timing
* Resource Timing
* First Paint ([FP](https://medium.com/@zizzamia/first-contentful-paint-with-a-touch-of-perfume-js-cd11dfd2e18f))

@@ -96,2 +97,17 @@ * First Contentful Paint ([FCP](https://medium.com/@zizzamia/first-contentful-paint-with-a-touch-of-perfume-js-cd11dfd2e18f))

### Resource Timing
Resource Timing collects performance metrics for document-dependent resources. Stuff like style sheets, scripts, images, et cetera.
Perfume helps expose all PerformanceResourceTiming entries and group data data consumption by Kb used.
```javascript
const perfume = new Perfume({
resourceTiming: true,
dataConsumption: true,
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})
});
// Perfume.js: dataConsumption { "css": 185.95, "fetch": 0, "img": 377.93, ... , "script": 8344.95 }
```
### First Paint ([FP](https://medium.com/@zizzamia/first-contentful-paint-with-a-touch-of-perfume-js-cd11dfd2e18f))

@@ -250,5 +266,25 @@

// Perfume.js config, supports AOT and DI
const analyticsTracker = function ({ metricName, data, duration }) {
switch(metricName) {
case 'navigationTiming':
myAnalyticsTool.track(metricName, data);
break;
case 'resourceTiming':
myAnalyticsTool.track(metricName, data);
break;
case 'dataConsumption':
myAnalyticsTool.track(metricName, data);
break;
default:
myAnalyticsTool.track(metricName, duration);
break;
}
})
export const PerfumeConfig = {
firstContentfulPaint: true,
firstInputDelay: true,
dataConsumption: true,
navigationTiming: true,
resourceTiming: true,
analyticsTracker,
};

@@ -277,5 +313,26 @@

const analyticsTracker = function ({ metricName, data, duration }) {
switch(metricName) {
case 'navigationTiming':
myAnalyticsTool.track(metricName, data);
break;
case 'resourceTiming':
myAnalyticsTool.track(metricName, data);
break;
case 'dataConsumption':
myAnalyticsTool.track(metricName, data);
break;
default:
myAnalyticsTool.track(metricName, duration);
break;
}
})
const perfume = new Perfume({
firstContentfulPaint: true,
firstInputDelay: true
firstInputDelay: true,
dataConsumption: true,
navigationTiming: true,
resourceTiming: true,
analyticsTracker,
});

@@ -338,2 +395,3 @@

navigationTiming: false,
resourceTiming: false,
// Analytics

@@ -346,3 +404,2 @@ analyticsTracker: options => {},

warning: false,
debugging: false,
};

@@ -354,3 +411,2 @@ ```

* `npm start`: Run `npm run build` in watch mode
* `npm run test`: Run test suite

@@ -357,0 +413,0 @@ * `npm run build`: Generate bundles and typings

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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