Huge News!Announcing our $40M Series B led by Abstract Ventures.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.8.1 to 5.0.0-rc.1

18

CHANGELOG.md
# Changelog
## 5.0.0-rc.1 (2020-3-14)
* **feat:** enabled `PerformanceObserver` for all browser
* **feat:** simplified the `analyticsTracker` by having all duration value inside the `data` property
### Breaking Changes
Until now, we allowed only Chrome to run the PerformanceObserver interface because of possible cross-browser issues. One in particular related to Firefox 58: https://bugzilla.mozilla.org/show_bug.cgi?id=1403027
Starting from Perfume.js v4.9.0, we are going to remove this limitation, and we are going to monitor any new open issues and address them immediately.
Having both `duration` and `data` inside the `analyticsTracker`, it started causing some confusion. Starting from v5, we will keep only `data` and have any information from `duration` contained inside `data`. Please make sure to change the code inside your `analyticsTracker`.
## 4.8.1 (2020-2-24)
* **feat:** added serviceWorkerStatus in navigatorInfo
## 4.8.0 (2020-2-23)
* **feat:** added support for Cumulative Layout Shift score #80
* **feat:** added support for Cumulative Layout Shift score [#80](https://github.com/Zizzamia/perfume.js/issues/80)

@@ -7,0 +23,0 @@ ## 4.7.5 (2020-2-22)

12

dist/es/perfume.js

@@ -149,3 +149,2 @@ var Perfume = /** @class */ (function () {

data: duration2Decimal,
duration: duration2Decimal,
customProperties: customProperties,

@@ -284,8 +283,6 @@ navigatorInfo: navigatorInfo,

/**
* For now only Chrome fully support the PerformanceObserver interface
* and the entryType "paint".
* Firefox 58: https://bugzilla.mozilla.org/show_bug.cgi?id=1403027
* Check PerformanceObserver interface is supported
*/
Perfume.prototype.isPerformanceObserverSupported = function () {
return this.w.chrome && 'PerformanceObserver' in this.w;
return 'PerformanceObserver' in this.w;
};

@@ -428,3 +425,3 @@ /**

measureName: measureName,
duration: duration2Decimal,
data: duration2Decimal,
navigatorInfo: navigatorInfo,

@@ -538,3 +535,3 @@ });

}
var measureName = options.measureName, data = options.data, duration = options.duration, customProperties = options.customProperties, navigatorInfo = options.navigatorInfo;
var measureName = options.measureName, data = options.data, customProperties = options.customProperties, navigatorInfo = options.navigatorInfo;
var eventProperties = customProperties ? customProperties : {};

@@ -545,3 +542,2 @@ // Send metric to custom Analytics service

data: data,
duration: duration,
eventProperties: eventProperties,

@@ -548,0 +544,0 @@ navigatorInformation: navigatorInfo,

@@ -151,3 +151,2 @@ "use strict";

data: duration2Decimal,
duration: duration2Decimal,
customProperties: customProperties,

@@ -286,8 +285,6 @@ navigatorInfo: navigatorInfo,

/**
* For now only Chrome fully support the PerformanceObserver interface
* and the entryType "paint".
* Firefox 58: https://bugzilla.mozilla.org/show_bug.cgi?id=1403027
* Check PerformanceObserver interface is supported
*/
Perfume.prototype.isPerformanceObserverSupported = function () {
return this.w.chrome && 'PerformanceObserver' in this.w;
return 'PerformanceObserver' in this.w;
};

@@ -430,3 +427,3 @@ /**

measureName: measureName,
duration: duration2Decimal,
data: duration2Decimal,
navigatorInfo: navigatorInfo,

@@ -540,3 +537,3 @@ });

}
var measureName = options.measureName, data = options.data, duration = options.duration, customProperties = options.customProperties, navigatorInfo = options.navigatorInfo;
var measureName = options.measureName, data = options.data, customProperties = options.customProperties, navigatorInfo = options.navigatorInfo;
var eventProperties = customProperties ? customProperties : {};

@@ -547,3 +544,2 @@ // Send metric to custom Analytics service

data: data,
duration: duration,
eventProperties: eventProperties,

@@ -550,0 +546,0 @@ navigatorInformation: navigatorInfo,

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

var t=function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.P("navigationTiming",this.j()),this.P("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,duration:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.P("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.P=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,duration:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.L=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.P("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.duration,e=t.B,r=t.R,h=e||{};this.config.analyticsTracker({metricName:i,data:s,duration:n,eventProperties:h,navigatorInformation:r})}},t}();export default t;
var t=function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.P("navigationTiming",this.j()),this.P("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.P("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.P=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,data:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.L=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.P("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.B,e=t.R,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},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;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.P(),this.L("navigationTiming",this.j()),this.L("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,duration:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.L("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.L=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,duration:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.L("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.duration,e=t.B,r=t.R,h=e||{};this.config.analyticsTracker({metricName:i,data:s,duration:n,eventProperties:h,navigatorInformation:r})}},t}()}();
var Perfume=function(){"use strict";return function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.P(),this.L("navigationTiming",this.j()),this.L("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.L("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.L=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,data:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.P=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.L("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.B,e=t.R,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t}()}();
//# sourceMappingURL=perfume.iife.min.js.map

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

"use strict";var Perfume=function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.I(),this.L("navigationTiming",this.j()),this.L("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,duration:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.L("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.L=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,duration:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.I=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.L("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.duration,e=t.B,r=t.R,h=e||{};this.config.analyticsTracker({metricName:i,data:s,duration:n,eventProperties:h,navigatorInformation:r})}},t}();module.exports=Perfume;
"use strict";var Perfume=function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.I(),this.L("navigationTiming",this.j()),this.L("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.L("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.at=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.ot&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.at()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.L=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,data:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.I=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.L("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.B,e=t.R,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},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).Perfume=i()}(this,(function(){"use strict";return function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.P("navigationTiming",this.j()),this.P("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var n=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var s=this.F(t),e=parseFloat(s.toFixed(2));delete this.u[t],this.q((function(){var s=n.M();s.isLowEndDevice=n.isLowEndDevice,s.isLowEndExperience=n.isLowEndExperience;var r={W:t,data:e,duration:e,B:i,R:s};n.log(r),n.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var n=this;setTimeout((function(){n.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.P("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.nt("first-input",this.A.bind(this))},t.prototype.st=function(){var t=this;this.m.et=this.nt("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.nt("largest-contentful-paint",(function(i){var n=i.pop();n&&(t.h=n.renderTime||n.loadTime)}))},t.prototype.ot=function(){var t=this;this.m.$=this.nt("layout-shift",(function(i){var n=i.pop();n&&!n.at&&n.value&&(t.i+=n.value)}))},t.prototype.I=function(){this.st(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.ot()},t.prototype.ut=function(){var t=this;this.nt("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return this.w.chrome&&"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),n=i[i.length-1];return n&&"measure"===n.entryType?n.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,n=t.responseEnd;return{fetchTime:n-t.fetchStart,workerTime:t.workerStart>0?n-t.workerStart:0,totalTime:n-t.requestStart,downloadTime:n-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.P=function(t,i){var n=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var s=this.M();s.isLowEndDevice=this.isLowEndDevice,s.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:t,data:i,R:s}),n.Z({W:t,data:i,R:s})}))},t.prototype.Y=function(t,i,n){var s=this;void 0===n&&(n="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:i,data:e+" "+n,R:r}),s.Z({W:i,duration:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.L=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",n="mark_"+t+"_end";return this.l.measure(t,i,n),this.ct(t)},t.prototype.nt=function(t,i){return this.vt=new PerformanceObserver((function(t){var n=t.getEntries();i(n)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(n){(!t.rt||t.rt&&n.name===t.rt)&&i.Y(n[t.J],t.W),i.m.et&&"first-contentful-paint"===n.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.P("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var n=t.decodedBodySize/1e3;i.v[t.initiatorType]+=n,i.v.total+=n}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,n=t.data,s=t.duration,e=t.B,r=t.R,h=e||{};this.config.analyticsTracker({metricName:i,data:n,duration:s,eventProperties:h,navigatorInformation:r})}},t}()}));
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).Perfume=i()}(this,(function(){"use strict";return function(){function t(t){var i=this;if(void 0===t&&(t={}),this.config={cumulativeLayoutShift:!1,dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="4.8.1",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=0,this.o="Recording already",this.u={},this.m={},this.v={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.w=window,this.l=window.performance,this.p=window.navigator,this.g="4g",this.T=!1,this.k=function(){i.d.hidden&&(i.s=i.d.hidden)},this.config=Object.assign({},this.config,t),this._()){if(this.N())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.P("navigationTiming",this.j()),this.P("networkInformation",this.C())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},O:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.g)||!!this.T)},O:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.D(this.o+" started."):(this.u[t]=!0,this.l.mark("mark_"+t+"_start"),this.s=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this._())if(this.u[t]){this.l.mark("mark_"+t+"_end");var n=this.F(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.q((function(){var n=s.M();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,B:i,R:n};s.log(r),s.Z(r)}))}else this.D(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){this.l.clearMarks("mark_"+t+"_start"),this.l.clearMarks("mark_"+t+"_end"),delete this.u[t]},t.prototype.A=function(t){this.G({H:t,W:"firstInputDelay",J:"duration"}),this.K(),this.U()},t.prototype.U=function(){this.V&&(clearTimeout(this.V),this.V=void 0,this.P("dataConsumption",this.v))},t.prototype.K=function(){this.m.X&&this.h&&(this.Y(this.h,"largestContentfulPaint"),this.m.X.disconnect()),this.m.$&&this.i>0&&(this.m.$.takeRecords(),this.Y(this.i,"cumulativeLayoutShiftScore",""),this.m.$.disconnect())},t.prototype.tt=function(){this.m.it=this.st("first-input",this.A.bind(this))},t.prototype.nt=function(){var t=this;this.m.et=this.st("paint",(function(i){t.G({H:i,rt:"first-paint",W:"firstPaint",J:"startTime"}),t.G({H:i,rt:"first-contentful-paint",W:"firstContentfulPaint",J:"startTime"})}))},t.prototype.ht=function(){var t=this;this.m.X=this.st("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.ot=function(){var t=this;this.m.$=this.st("layout-shift",(function(i){var s=i.pop();s&&!s.at&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.nt(),this.tt(),this.ht(),(this.config.resourceTiming||this.config.dataConsumption)&&this.ut(),this.ot()},t.prototype.ut=function(){var t=this;this.st("resource",(function(i){t.ft({H:i})})),this.V=setTimeout((function(){t.U()}),15e3)},t.prototype._=function(){return this.l&&!!this.l.getEntriesByType&&!!this.l.now&&!!this.l.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.ct=function(t){var i=this.l.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.M=function(){return this.p?{deviceMemory:this.p.deviceMemory?this.p.deviceMemory:0,hardwareConcurrency:this.p.hardwareConcurrency?this.p.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.p?this.p.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this._())return{};var t=performance.getEntriesByType("navigation")[0];if(!t)return{};var i=t.responseStart,s=t.responseEnd;return{fetchTime:s-t.fetchStart,workerTime:t.workerStart>0?s-t.workerStart:0,totalTime:s-t.requestStart,downloadTime:s-i,timeToFirstByte:i-t.requestStart,headerSize:t.transferSize-t.encodedBodySize||0,dnsLookupTime:t.domainLookupEnd-t.domainLookupStart}},t.prototype.C=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.g=t.effectiveType,this.T=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.P=function(t,i){var s=this;Object.keys(i).forEach((function(t){"number"==typeof i[t]&&(i[t]=parseFloat(i[t].toFixed(2)))}));var n=this.M();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.q((function(){s.log({W:t,data:i,R:n}),s.Z({W:t,data:i,R:n})}))},t.prototype.Y=function(t,i,s){var n=this;void 0===s&&(s="ms");var e=parseFloat(t.toFixed(2));if(!(e>this.config.maxMeasureTime||e<=0)){var r=this.M();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.q((function(){n.log({W:i,data:e+" "+s,R:r}),n.Z({W:i,data:e,R:r})}))}},t.prototype.log=function(t){if(!this.s&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.W+" ","color:#ff6d00;font-size:11px;",t.data,t.R)}},t.prototype.D=function(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)},t.prototype.L=function(){void 0!==this.d.hidden&&this.d.addEventListener("visibilitychange",this.k)},t.prototype.F=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.l.measure(t,i,s),this.ct(t)},t.prototype.st=function(t,i){return this.vt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.vt.observe({type:t,buffered:!0}),this.vt},t.prototype.G=function(t){var i=this;t.H.forEach((function(s){(!t.rt||t.rt&&s.name===t.rt)&&i.Y(s[t.J],t.W),i.m.et&&"first-contentful-paint"===s.name&&i.m.et.disconnect()})),this.m.it&&"firstInputDelay"===t.W&&this.m.it.disconnect()},t.prototype.ft=function(t){var i=this;t.H.forEach((function(t){if(i.config.resourceTiming&&i.P("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.v[t.initiatorType]+=s,i.v.total+=s}}))},t.prototype.q=function(t){"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:3e3}):t()},t.prototype.Z=function(t){if(!this.s){var i=t.W,s=t.data,n=t.B,e=t.R,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t}()}));
//# sourceMappingURL=perfume.umd.min.js.map
/*!
* Perfume.js v4.8.1 (http://zizzamia.github.io/perfume)
* Perfume.js v5.0.0-rc.1 (http://zizzamia.github.io/perfume)
* Copyright 2020 Leonardo Zizzamia (https://github.com/Zizzamia/perfume.js/graphs/contributors)

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

data?: any;
duration?: number;
customProperties?: object;

@@ -175,5 +174,3 @@ navigatorInfo: INavigatorInfo;

/**
* For now only Chrome fully support the PerformanceObserver interface
* and the entryType "paint".
* Firefox 58: https://bugzilla.mozilla.org/show_bug.cgi?id=1403027
* Check PerformanceObserver interface is supported
*/

@@ -180,0 +177,0 @@ private isPerformanceObserverSupported;

{
"name": "perfume.js",
"version": "4.8.1",
"version": "5.0.0-rc.1",
"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.",

@@ -95,3 +95,3 @@ "keywords": [

"colors": "1.4.0",
"commitizen": "4.0.3",
"commitizen": "^4.0.4",
"coveralls": "3.0.7",

@@ -98,0 +98,0 @@ "husky": "3.0.9",

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

# [Perfume.js v4.8.1](http://perfumejs.com)
# [Perfume.js v5.0.0-rc.1](http://perfumejs.com)

@@ -73,3 +73,3 @@ [![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)

analyticsTracker: (options) => {
const { metricName, data, duration, navigatorInformation } = options;
const { metricName, data, navigatorInformation } = options;
switch (metricName) {

@@ -87,12 +87,12 @@ case 'navigationTiming':

case 'firstPaint':
myAnalyticsTool.track('firstPaint', { duration });
myAnalyticsTool.track('firstPaint', { duration: data });
break;
case 'firstContentfulPaint':
myAnalyticsTool.track('firstContentfulPaint', { duration });
myAnalyticsTool.track('firstContentfulPaint', { duration: data });
break;
case 'firstInputDelay':
myAnalyticsTool.track('firstInputDelay', { duration });
myAnalyticsTool.track('firstInputDelay', { duration: data });
break;
case 'largestContentfulPaint':
myAnalyticsTool.track('largestContentfulPaint', { duration });
myAnalyticsTool.track('largestContentfulPaint', { duration: data });
break;

@@ -159,4 +159,4 @@ default:

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -175,4 +175,4 @@ });

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -191,4 +191,4 @@ });

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -207,4 +207,4 @@ });

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -234,4 +234,4 @@ });

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -253,4 +253,4 @@ });

const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
})

@@ -268,8 +268,8 @@ });

Save the duration and print it out exactly the way you want it.
Save the data and print it out exactly the way you want it.
```javascript
const perfume = new Perfume({
analyticsTracker: ({ metricName, duration }) => {
myAnalyticsTool.track(metricName, duration);
analyticsTracker: ({ metricName, data }) => {
myAnalyticsTool.track(metricName, data);
}),

@@ -280,3 +280,3 @@ logPrefix: '🍹 HayesValley.js:'

fibonacci(400);
const duration = perfume.end('fibonacci');
perfume.end('fibonacci');
// 🍹 HayesValley.js: Custom logging 0.14 ms

@@ -286,136 +286,2 @@ ```

## Frameworks
### Angular
Wth the Angular framework, we can start configuring Perfume to collect the initial performance metrics (eg. FCP, FID). Make sure to import the `PefumeModule` at first inside the `NgModule` to let the PerformanceObserver work correctly.
In a large application use the `@PerfumeAfterViewInit()` decorator to monitor the rendering performance of the most complex components. Avoid using it inside a NgFor, instead focus on components that include a collection of smaller components.
The `NgPerfume` service exposes all the methods and property of the `perfume` instance, you can annotate component lifecycles combined with APIs calls to measure how long it takes to paint the component.
```javascript
import { NgPerfume, PerfumeModule, PerfumeAfterViewInit } from 'perfume.js/angular';
import { AppComponent } from './app.component';
import { AppApi } from './app-api';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less'],
})
@PerfumeAfterViewInit('AppComponent')
export class AppComponent implements AfterViewInit {
data: AwesomeType;
constructor(public perfume: NgPerfume) {
// Start measure component time to paint
this.perfume.start('AppComponentAfterPaint');
}
ngAfterViewInit() {
this.loadAwesomeData();
}
loadAwesomeData = async () => {
await AppApi.loadAmazingData();
this.data = AppApi.loadAwesomeData();
// End measure component time to paint
this.perfume.endPaint('AppComponentAfterPaint');
}
}
// 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 = {
dataConsumption: true,
resourceTiming: true,
analyticsTracker,
};
@NgModule({
declarations: [AppComponent],
imports: [PerfumeModule.forRoot(PerfumeConfig), BrowserModule],
bootstrap: [AppComponent],
})
export class AppModule {}
```
![Angular Performance Decorator](https://github.com/Zizzamia/perfume.js/blob/master/docs/src/assets/angular-performance-decorator.png)
### React
In combination with the React framework, we can start configuring Perfume to collect the initial performance metrics (eg. FCP, FID).
Use `perfume.start()` and `perfume.endPaint()` into a component lifecycle mixed with APIs calls to measure how long it takes to paint the component.
```javascript
import React from 'react';
import Perfume from 'perfume.js';
import { AppApi } from './AppApi';
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({
dataConsumption: true,
resourceTiming: true,
analyticsTracker,
});
export default class App extends React.Component {
constructor() {
// Start measure component time to paint
perfume.start('AppAfterPaint');
}
loadData = async () => {
await AppApi.loadAmazingData();
await AppApi.loadAwesomeData();
// End measure component time to paint
perfume.endPaint('AppAfterPaint');
}
render() {
const data = this.loadData();
return (
<div>
<h2>Awesome App</h2>
<div>{data}</div>
</div>
);
}
}
```
<br />
## Analytics

@@ -430,7 +296,6 @@

data,
duration,
metricName,
navigatorInformation,
} = options;
myAnalyticsTool.track(data, duration, metricName, navigatorInformation);
myAnalyticsTool.track(data, metricName, navigatorInformation);
})

@@ -450,2 +315,3 @@ });

// Metrics
cumulativeLayoutShift: false,
dataConsumption: false,

@@ -452,0 +318,0 @@ resourceTiming: false,

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