perfume.js
Advanced tools
Comparing version 5.0.0-rc.3 to 5.0.0-rc.4
# Changelog | ||
## 5.0.0-rc.4 (2020-3-19) | ||
* **fix:** solved issue with `storageEstimate` and created his own event | ||
* **fix:** removed extra calls for `totalBlockingTime` | ||
## 5.0.0-rc.3 (2020-3-18) | ||
@@ -4,0 +9,0 @@ |
@@ -16,6 +16,7 @@ var Perfume = /** @class */ (function () { | ||
this.copyright = '© 2020 Leonardo Zizzamia'; | ||
this.version = '5.0.0-rc.3'; | ||
this.version = '5.0.0-rc.4'; | ||
this.c = window.console; | ||
this.cumulativeLayoutShiftScore = 0; | ||
this.d = document; | ||
this.hasSetStorageEstimate = false; | ||
this.isHidden = false; | ||
@@ -36,4 +37,2 @@ this.lcpDuration = 0; | ||
}; | ||
this.storageEstimateQuota = null; | ||
this.storageEstimateUsage = null; | ||
this.totalBlockingTimeScore = 0; | ||
@@ -51,4 +50,2 @@ this.w = window; | ||
} | ||
// Let's estimate our storage capacity | ||
this.setStorageEstimate(); | ||
// Checks if use Performance or the EmulatedPerformance instance | ||
@@ -71,2 +68,4 @@ if (this.isPerformanceObserverSupported()) { | ||
this.logData('networkInformation', this.getNetworkInformation()); | ||
// Let's estimate our storage capacity | ||
this.initStorageEstimate(); | ||
} | ||
@@ -182,2 +181,5 @@ Object.defineProperty(Perfume.prototype, "isLowEndDevice", { | ||
Perfume.prototype.convertToKB = function (bytes) { | ||
if (typeof bytes !== 'number') { | ||
return null; | ||
} | ||
return parseFloat((bytes / Math.pow(1024, 2)).toFixed(2)); | ||
@@ -225,3 +227,3 @@ }; | ||
var _this = this; | ||
// TBT with 5 second delay after LCP | ||
// TBT with 5 second delay after FID | ||
setTimeout(function () { | ||
@@ -232,3 +234,3 @@ if (_this.perfObservers.tbt && _this.totalBlockingTimeScore) { | ||
}, 5000); | ||
// TBT with 10 second delay after LCP | ||
// TBT with 10 second delay after FID | ||
setTimeout(function () { | ||
@@ -320,5 +322,2 @@ if (_this.perfObservers.tbt) { | ||
}); | ||
setTimeout(function () { | ||
_this.disconnecTotalBlockingTime(); | ||
}, 15000); | ||
}; | ||
@@ -363,4 +362,2 @@ /** | ||
* - unsupported: the user's browser does not support service worker | ||
* 4. Storage quota | ||
* 5. Storage usage | ||
*/ | ||
@@ -381,4 +378,2 @@ Perfume.prototype.getNavigatorInfo = function () { | ||
: 'unsupported', | ||
storageEstimateQuota: this.storageEstimateQuota, | ||
storageEstimateUsage: this.storageEstimateUsage, | ||
}; | ||
@@ -591,5 +586,6 @@ } | ||
*/ | ||
Perfume.prototype.pushTask = function (cb) { | ||
Perfume.prototype.pushTask = function (cb, delay) { | ||
if (delay === void 0) { delay = 3000; } | ||
if ('requestIdleCallback' in this.w) { | ||
this.w.requestIdleCallback(cb, { timeout: 3000 }); | ||
this.w.requestIdleCallback(cb, { timeout: delay }); | ||
} | ||
@@ -623,3 +619,3 @@ else { | ||
*/ | ||
Perfume.prototype.setStorageEstimate = function () { | ||
Perfume.prototype.initStorageEstimate = function () { | ||
var _this = this; | ||
@@ -629,11 +625,14 @@ if (!this.wn || !this.wn.storage) { | ||
} | ||
navigator.storage.estimate().then(function (storageInfo) { | ||
_this.storageEstimateQuota = | ||
typeof storageInfo.quota === 'number' | ||
? _this.convertToKB(storageInfo.quota) | ||
: null; | ||
_this.storageEstimateUsage = | ||
typeof storageInfo.usage === 'number' | ||
? _this.convertToKB(storageInfo.usage) | ||
: null; | ||
this.wn.storage.estimate().then(function (storageInfo) { | ||
var estimateUsageDetails = {}; | ||
if ('usageDetails' in storageInfo) { | ||
estimateUsageDetails = storageInfo.usageDetails; | ||
} | ||
_this.logData('storageEstimate', { | ||
storageEstimateQuota: _this.convertToKB(storageInfo.quota), | ||
storageEstimateUsage: _this.convertToKB(storageInfo.usage), | ||
storageEstimateCaches: _this.convertToKB(estimateUsageDetails.caches), | ||
storageEstimateIndexedDB: _this.convertToKB(estimateUsageDetails.indexedDB), | ||
storageEstimatSW: _this.convertToKB(estimateUsageDetails.serviceWorkerRegistrations), | ||
}); | ||
}); | ||
@@ -640,0 +639,0 @@ }; |
@@ -18,6 +18,7 @@ "use strict"; | ||
this.copyright = '© 2020 Leonardo Zizzamia'; | ||
this.version = '5.0.0-rc.3'; | ||
this.version = '5.0.0-rc.4'; | ||
this.c = window.console; | ||
this.cumulativeLayoutShiftScore = 0; | ||
this.d = document; | ||
this.hasSetStorageEstimate = false; | ||
this.isHidden = false; | ||
@@ -38,4 +39,2 @@ this.lcpDuration = 0; | ||
}; | ||
this.storageEstimateQuota = null; | ||
this.storageEstimateUsage = null; | ||
this.totalBlockingTimeScore = 0; | ||
@@ -53,4 +52,2 @@ this.w = window; | ||
} | ||
// Let's estimate our storage capacity | ||
this.setStorageEstimate(); | ||
// Checks if use Performance or the EmulatedPerformance instance | ||
@@ -73,2 +70,4 @@ if (this.isPerformanceObserverSupported()) { | ||
this.logData('networkInformation', this.getNetworkInformation()); | ||
// Let's estimate our storage capacity | ||
this.initStorageEstimate(); | ||
} | ||
@@ -184,2 +183,5 @@ Object.defineProperty(Perfume.prototype, "isLowEndDevice", { | ||
Perfume.prototype.convertToKB = function (bytes) { | ||
if (typeof bytes !== 'number') { | ||
return null; | ||
} | ||
return parseFloat((bytes / Math.pow(1024, 2)).toFixed(2)); | ||
@@ -227,3 +229,3 @@ }; | ||
var _this = this; | ||
// TBT with 5 second delay after LCP | ||
// TBT with 5 second delay after FID | ||
setTimeout(function () { | ||
@@ -234,3 +236,3 @@ if (_this.perfObservers.tbt && _this.totalBlockingTimeScore) { | ||
}, 5000); | ||
// TBT with 10 second delay after LCP | ||
// TBT with 10 second delay after FID | ||
setTimeout(function () { | ||
@@ -322,5 +324,2 @@ if (_this.perfObservers.tbt) { | ||
}); | ||
setTimeout(function () { | ||
_this.disconnecTotalBlockingTime(); | ||
}, 15000); | ||
}; | ||
@@ -365,4 +364,2 @@ /** | ||
* - unsupported: the user's browser does not support service worker | ||
* 4. Storage quota | ||
* 5. Storage usage | ||
*/ | ||
@@ -383,4 +380,2 @@ Perfume.prototype.getNavigatorInfo = function () { | ||
: 'unsupported', | ||
storageEstimateQuota: this.storageEstimateQuota, | ||
storageEstimateUsage: this.storageEstimateUsage, | ||
}; | ||
@@ -593,5 +588,6 @@ } | ||
*/ | ||
Perfume.prototype.pushTask = function (cb) { | ||
Perfume.prototype.pushTask = function (cb, delay) { | ||
if (delay === void 0) { delay = 3000; } | ||
if ('requestIdleCallback' in this.w) { | ||
this.w.requestIdleCallback(cb, { timeout: 3000 }); | ||
this.w.requestIdleCallback(cb, { timeout: delay }); | ||
} | ||
@@ -625,3 +621,3 @@ else { | ||
*/ | ||
Perfume.prototype.setStorageEstimate = function () { | ||
Perfume.prototype.initStorageEstimate = function () { | ||
var _this = this; | ||
@@ -631,11 +627,14 @@ if (!this.wn || !this.wn.storage) { | ||
} | ||
navigator.storage.estimate().then(function (storageInfo) { | ||
_this.storageEstimateQuota = | ||
typeof storageInfo.quota === 'number' | ||
? _this.convertToKB(storageInfo.quota) | ||
: null; | ||
_this.storageEstimateUsage = | ||
typeof storageInfo.usage === 'number' | ||
? _this.convertToKB(storageInfo.usage) | ||
: null; | ||
this.wn.storage.estimate().then(function (storageInfo) { | ||
var estimateUsageDetails = {}; | ||
if ('usageDetails' in storageInfo) { | ||
estimateUsageDetails = storageInfo.usageDetails; | ||
} | ||
_this.logData('storageEstimate', { | ||
storageEstimateQuota: _this.convertToKB(storageInfo.quota), | ||
storageEstimateUsage: _this.convertToKB(storageInfo.usage), | ||
storageEstimateCaches: _this.convertToKB(estimateUsageDetails.caches), | ||
storageEstimateIndexedDB: _this.convertToKB(estimateUsageDetails.indexedDB), | ||
storageEstimatSW: _this.convertToKB(estimateUsageDetails.serviceWorkerRegistrations), | ||
}); | ||
}); | ||
@@ -642,0 +641,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var t=function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.3",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.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.storageEstimateQuota=null,this.storageEstimateUsage=null,this.v=0,this.w=window,this.p=window.performance,this.g=window.navigator,this.T="4g",this.k=!1,this.config=Object.assign({},this.config,t),this._()){if(this.N(),this.I())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.j("navigationTiming",this.C()),this.j("networkInformation",this.O())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.g.hardwareConcurrency&&this.g.hardwareConcurrency<=4)||!!(this.g.deviceMemory&&this.g.deviceMemory<=4)},F:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.T)||!!this.k)},F:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.B(this.o+" started."):(this.u[t]=!0,this.p.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.p.mark("mark_"+t+"_end");var n=this.D(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.M((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,R:i,U:n};s.log(r),s.Z(r)}))}else this.B(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.u[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.A=function(t){return parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.G=function(){this.d.hidden&&(this.s=this.d.hidden)},t.prototype.H=function(t){this.J({K:t,W:"firstInputDelay",V:"duration"}),this.X(),this.Y(),this.$()},t.prototype.Y=function(){this.tt&&(clearTimeout(this.tt),this.tt=void 0,this.j("dataConsumption",this.l))},t.prototype.X=function(){this.m.it&&this.h&&(this.st(this.h,"largestContentfulPaint"),this.m.it.disconnect()),this.m.nt&&this.i>0&&(this.m.nt.takeRecords(),this.st(this.i,"cumulativeLayoutShift",""),this.m.nt.disconnect()),this.m.et&&this.v&&this.st(this.v,"totalBlockingTime")},t.prototype.$=function(){var t=this;setTimeout((function(){t.m.et&&t.v&&t.st(t.v,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.m.et&&(t.v&&t.st(t.v,"totalBlockingTime10S"),t.m.et.disconnect())}),1e4)},t.prototype.rt=function(){this.m.ht=this.ot("first-input",this.H.bind(this))},t.prototype.at=function(){var t=this;this.m.ut=this.ot("paint",(function(i){t.J({K:i,ft:"first-paint",W:"firstPaint",V:"startTime"}),t.J({K:i,ft:"first-contentful-paint",W:"firstContentfulPaint",V:"startTime"})}))},t.prototype.ct=function(){var t=this;this.m.it=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.m.nt=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.vt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.at(),this.rt(),this.ct(),(this.config.resourceTiming||this.config.dataConsumption)&&this.dt(),this.lt()},t.prototype.dt=function(){var t=this;this.ot("resource",(function(i){t.pt({K:i})})),this.tt=setTimeout((function(){t.Y()}),15e3)},t.prototype.gt=function(){var t=this;this.m.et=this.ot("longtask",(function(i){t.Tt({K:i})})),setTimeout((function(){t.$()}),15e3)},t.prototype._=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.I=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.p.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=function(){return this.g?{deviceMemory:this.g.deviceMemory?this.g.deviceMemory:0,hardwareConcurrency:this.g.hardwareConcurrency?this.g.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.g?this.g.serviceWorker.controller?"controlled":"supported":"unsupported",storageEstimateQuota:this.storageEstimateQuota,storageEstimateUsage:this.storageEstimateUsage}:{}},t.prototype.C=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.O=function(){if("connection"in this.g){var t=this.g.connection;return"object"!=typeof t?{}:(this.T=t.effectiveType,this.k=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.j=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.M((function(){s.log({W:t,data:i,U:n}),s.Z({W:t,data:i,U:n})}))},t.prototype.st=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.M((function(){n.log({W:i,data:e+" "+s,U:r}),n.Z({W:i,data:e,U: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.U)}},t.prototype.B=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.G.bind(this))},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.p.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.J=function(t){var i=this;t.K.forEach((function(s){(!t.ft||t.ft&&s.name===t.ft)&&i.st(s[t.V],t.W),i.m.ut&&"first-contentful-paint"===s.name&&(i.gt(),i.m.ut.disconnect())})),this.m.ht&&"firstInputDelay"===t.W&&this.m.ht.disconnect()},t.prototype.pt=function(t){var i=this;t.K.forEach((function(t){if(i.config.resourceTiming&&i.j("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.Tt=function(t){var i=this;t.K.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.v+=s)}}))},t.prototype.M=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.R,e=t.U,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.N=function(){var t=this;this.g&&this.g.kt&&navigator.kt.estimate().then((function(i){t.storageEstimateQuota="number"==typeof i.wt?t.A(i.wt):null,t.storageEstimateUsage="number"==typeof i._t?t.A(i._t):null}))},t}();export default t; | ||
var t=function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.4",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=!1,this.o=0,this.u="Recording already",this.m={},this.v={},this.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.g=0,this.w=window,this.p=window.performance,this.T=window.navigator,this.k="4g",this._=!1,this.config=Object.assign({},this.config,t),this.I()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.C("navigationTiming",this.j()),this.C("networkInformation",this.D()),this.O()}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.T.hardwareConcurrency&&this.T.hardwareConcurrency<=4)||!!(this.T.deviceMemory&&this.T.deviceMemory<=4)},S:!0,B:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.k)||!!this._)},S:!0,B:!0}),t.prototype.start=function(t){this.I()&&(this.m[t]?this.F(this.u+" started."):(this.m[t]=!0,this.p.mark("mark_"+t+"_start"),this.h=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this.I())if(this.m[t]){this.p.mark("mark_"+t+"_end");var n=this.M(t),e=parseFloat(n.toFixed(2));delete this.m[t],this.W((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={R:t,data:e,U:i,Z:n};s.log(r),s.A(r)}))}else this.F(this.u+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.m[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.G=function(t){return"number"!=typeof t?null:parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.H=function(){this.d.hidden&&(this.h=this.d.hidden)},t.prototype.J=function(t){this.K({V:t,R:"firstInputDelay",X:"duration"}),this.Y(),this.$(),this.tt()},t.prototype.$=function(){this.it&&(clearTimeout(this.it),this.it=void 0,this.C("dataConsumption",this.l))},t.prototype.Y=function(){this.v.st&&this.o&&(this.nt(this.o,"largestContentfulPaint"),this.v.st.disconnect()),this.v.et&&this.i>0&&(this.v.et.takeRecords(),this.nt(this.i,"cumulativeLayoutShift",""),this.v.et.disconnect()),this.v.rt&&this.g&&this.nt(this.g,"totalBlockingTime")},t.prototype.tt=function(){var t=this;setTimeout((function(){t.v.rt&&t.g&&t.nt(t.g,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.v.rt&&(t.g&&t.nt(t.g,"totalBlockingTime10S"),t.v.rt.disconnect())}),1e4)},t.prototype.at=function(){this.v.ht=this.ot("first-input",this.J.bind(this))},t.prototype.ut=function(){var t=this;this.v.ft=this.ot("paint",(function(i){t.K({V:i,ct:"first-paint",R:"firstPaint",X:"startTime"}),t.K({V:i,ct:"first-contentful-paint",R:"firstContentfulPaint",X:"startTime"})}))},t.prototype.vt=function(){var t=this;this.v.st=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.o=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.v.et=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.dt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.ut(),this.at(),this.vt(),(this.config.resourceTiming||this.config.dataConsumption)&&this.gt(),this.lt()},t.prototype.gt=function(){var t=this;this.ot("resource",(function(i){t.pt({V:i})})),this.it=setTimeout((function(){t.$()}),15e3)},t.prototype.Tt=function(){var t=this;this.v.rt=this.ot("longtask",(function(i){t.kt({V:i})}))},t.prototype.I=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.p.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=function(){return this.T?{deviceMemory:this.T.deviceMemory?this.T.deviceMemory:0,hardwareConcurrency:this.T.hardwareConcurrency?this.T.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.T?this.T.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this.I())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.D=function(){if("connection"in this.T){var t=this.T.connection;return"object"!=typeof t?{}:(this.k=t.effectiveType,this._=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.C=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.W((function(){s.log({R:t,data:i,Z:n}),s.A({R:t,data:i,Z:n})}))},t.prototype.nt=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.W((function(){n.log({R:i,data:e+" "+s,Z:r}),n.A({R:i,data:e,Z:r})}))}},t.prototype.log=function(t){if(!this.h&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.R+" ","color:#ff6d00;font-size:11px;",t.data,t.Z)}},t.prototype.F=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.H.bind(this))},t.prototype.M=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.p.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.K=function(t){var i=this;t.V.forEach((function(s){(!t.ct||t.ct&&s.name===t.ct)&&i.nt(s[t.X],t.R),i.v.ft&&"first-contentful-paint"===s.name&&(i.Tt(),i.v.ft.disconnect())})),this.v.ht&&"firstInputDelay"===t.R&&this.v.ht.disconnect()},t.prototype.pt=function(t){var i=this;t.V.forEach((function(t){if(i.config.resourceTiming&&i.C("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.kt=function(t){var i=this;t.V.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.g+=s)}}))},t.prototype.W=function(t,i){void 0===i&&(i=3e3),"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:i}):t()},t.prototype.A=function(t){if(!this.h){var i=t.R,s=t.data,n=t.U,e=t.Z,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.O=function(){var t=this;this.T&&this.T.storage&&this.T.storage.estimate().then((function(i){var s={};"usageDetails"in i&&(s=i.usageDetails),t.C("storageEstimate",{storageEstimateQuota:t.G(i.quota),storageEstimateUsage:t.G(i.usage),storageEstimateCaches:t.G(s.caches),storageEstimateIndexedDB:t.G(s.indexedDB),storageEstimatSW:t.G(s.serviceWorkerRegistrations)})}))},t}();export default t; | ||
//# sourceMappingURL=perfume.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
var Perfume=function(){"use strict";return function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.3",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.storageEstimateQuota=null,this.storageEstimateUsage=null,this.l=0,this.w=window,this.g=window.performance,this.p=window.navigator,this.T="4g",this.k=!1,this.config=Object.assign({},this.config,t),this._()){if(this.N(),this.I())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.j("navigationTiming",this.C()),this.j("networkInformation",this.O())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},F:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.T)||!!this.k)},F:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.B(this.o+" started."):(this.u[t]=!0,this.g.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.g.mark("mark_"+t+"_end");var n=this.D(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.M((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,R:i,U:n};s.log(r),s.Z(r)}))}else this.B(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.u[t],this.g.clearMarks&&(this.g.clearMarks("mark_"+t+"_start"),this.g.clearMarks("mark_"+t+"_end"))},t.prototype.A=function(t){return parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.G=function(){this.d.hidden&&(this.s=this.d.hidden)},t.prototype.H=function(t){this.J({K:t,W:"firstInputDelay",V:"duration"}),this.X(),this.Y(),this.$()},t.prototype.Y=function(){this.tt&&(clearTimeout(this.tt),this.tt=void 0,this.j("dataConsumption",this.v))},t.prototype.X=function(){this.m.it&&this.h&&(this.st(this.h,"largestContentfulPaint"),this.m.it.disconnect()),this.m.nt&&this.i>0&&(this.m.nt.takeRecords(),this.st(this.i,"cumulativeLayoutShift",""),this.m.nt.disconnect()),this.m.et&&this.l&&this.st(this.l,"totalBlockingTime")},t.prototype.$=function(){var t=this;setTimeout((function(){t.m.et&&t.l&&t.st(t.l,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.m.et&&(t.l&&t.st(t.l,"totalBlockingTime10S"),t.m.et.disconnect())}),1e4)},t.prototype.rt=function(){this.m.ht=this.ot("first-input",this.H.bind(this))},t.prototype.at=function(){var t=this;this.m.ut=this.ot("paint",(function(i){t.J({K:i,ft:"first-paint",W:"firstPaint",V:"startTime"}),t.J({K:i,ft:"first-contentful-paint",W:"firstContentfulPaint",V:"startTime"})}))},t.prototype.ct=function(){var t=this;this.m.it=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.vt=function(){var t=this;this.m.nt=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.lt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.at(),this.rt(),this.ct(),(this.config.resourceTiming||this.config.dataConsumption)&&this.dt(),this.vt()},t.prototype.dt=function(){var t=this;this.ot("resource",(function(i){t.gt({K:i})})),this.tt=setTimeout((function(){t.Y()}),15e3)},t.prototype.pt=function(){var t=this;this.m.et=this.ot("longtask",(function(i){t.Tt({K:i})})),setTimeout((function(){t.$()}),15e3)},t.prototype._=function(){return this.g&&!!this.g.getEntriesByType&&!!this.g.now&&!!this.g.mark},t.prototype.I=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.g.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=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",storageEstimateQuota:this.storageEstimateQuota,storageEstimateUsage:this.storageEstimateUsage}:{}},t.prototype.C=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.O=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.T=t.effectiveType,this.k=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.j=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.M((function(){s.log({W:t,data:i,U:n}),s.Z({W:t,data:i,U:n})}))},t.prototype.st=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.M((function(){n.log({W:i,data:e+" "+s,U:r}),n.Z({W:i,data:e,U: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.U)}},t.prototype.B=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.G.bind(this))},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.g.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.J=function(t){var i=this;t.K.forEach((function(s){(!t.ft||t.ft&&s.name===t.ft)&&i.st(s[t.V],t.W),i.m.ut&&"first-contentful-paint"===s.name&&(i.pt(),i.m.ut.disconnect())})),this.m.ht&&"firstInputDelay"===t.W&&this.m.ht.disconnect()},t.prototype.gt=function(t){var i=this;t.K.forEach((function(t){if(i.config.resourceTiming&&i.j("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.Tt=function(t){var i=this;t.K.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.l+=s)}}))},t.prototype.M=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.R,e=t.U,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.N=function(){var t=this;this.p&&this.p.kt&&navigator.kt.estimate().then((function(i){t.storageEstimateQuota="number"==typeof i.wt?t.A(i.wt):null,t.storageEstimateUsage="number"==typeof i._t?t.A(i._t):null}))},t}()}(); | ||
var Perfume=function(){"use strict";return function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.4",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=!1,this.o=0,this.u="Recording already",this.m={},this.v={},this.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.g=0,this.w=window,this.p=window.performance,this.T=window.navigator,this.k="4g",this._=!1,this.config=Object.assign({},this.config,t),this.I()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.C("navigationTiming",this.j()),this.C("networkInformation",this.D()),this.O()}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.T.hardwareConcurrency&&this.T.hardwareConcurrency<=4)||!!(this.T.deviceMemory&&this.T.deviceMemory<=4)},S:!0,B:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.k)||!!this._)},S:!0,B:!0}),t.prototype.start=function(t){this.I()&&(this.m[t]?this.F(this.u+" started."):(this.m[t]=!0,this.p.mark("mark_"+t+"_start"),this.h=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this.I())if(this.m[t]){this.p.mark("mark_"+t+"_end");var n=this.M(t),e=parseFloat(n.toFixed(2));delete this.m[t],this.W((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={R:t,data:e,U:i,Z:n};s.log(r),s.A(r)}))}else this.F(this.u+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.m[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.G=function(t){return"number"!=typeof t?null:parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.H=function(){this.d.hidden&&(this.h=this.d.hidden)},t.prototype.J=function(t){this.K({V:t,R:"firstInputDelay",X:"duration"}),this.Y(),this.$(),this.tt()},t.prototype.$=function(){this.it&&(clearTimeout(this.it),this.it=void 0,this.C("dataConsumption",this.l))},t.prototype.Y=function(){this.v.st&&this.o&&(this.nt(this.o,"largestContentfulPaint"),this.v.st.disconnect()),this.v.et&&this.i>0&&(this.v.et.takeRecords(),this.nt(this.i,"cumulativeLayoutShift",""),this.v.et.disconnect()),this.v.rt&&this.g&&this.nt(this.g,"totalBlockingTime")},t.prototype.tt=function(){var t=this;setTimeout((function(){t.v.rt&&t.g&&t.nt(t.g,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.v.rt&&(t.g&&t.nt(t.g,"totalBlockingTime10S"),t.v.rt.disconnect())}),1e4)},t.prototype.at=function(){this.v.ht=this.ot("first-input",this.J.bind(this))},t.prototype.ut=function(){var t=this;this.v.ft=this.ot("paint",(function(i){t.K({V:i,ct:"first-paint",R:"firstPaint",X:"startTime"}),t.K({V:i,ct:"first-contentful-paint",R:"firstContentfulPaint",X:"startTime"})}))},t.prototype.vt=function(){var t=this;this.v.st=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.o=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.v.et=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.dt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.ut(),this.at(),this.vt(),(this.config.resourceTiming||this.config.dataConsumption)&&this.gt(),this.lt()},t.prototype.gt=function(){var t=this;this.ot("resource",(function(i){t.pt({V:i})})),this.it=setTimeout((function(){t.$()}),15e3)},t.prototype.Tt=function(){var t=this;this.v.rt=this.ot("longtask",(function(i){t.kt({V:i})}))},t.prototype.I=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.p.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=function(){return this.T?{deviceMemory:this.T.deviceMemory?this.T.deviceMemory:0,hardwareConcurrency:this.T.hardwareConcurrency?this.T.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.T?this.T.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this.I())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.D=function(){if("connection"in this.T){var t=this.T.connection;return"object"!=typeof t?{}:(this.k=t.effectiveType,this._=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.C=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.W((function(){s.log({R:t,data:i,Z:n}),s.A({R:t,data:i,Z:n})}))},t.prototype.nt=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.W((function(){n.log({R:i,data:e+" "+s,Z:r}),n.A({R:i,data:e,Z:r})}))}},t.prototype.log=function(t){if(!this.h&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.R+" ","color:#ff6d00;font-size:11px;",t.data,t.Z)}},t.prototype.F=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.H.bind(this))},t.prototype.M=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.p.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.K=function(t){var i=this;t.V.forEach((function(s){(!t.ct||t.ct&&s.name===t.ct)&&i.nt(s[t.X],t.R),i.v.ft&&"first-contentful-paint"===s.name&&(i.Tt(),i.v.ft.disconnect())})),this.v.ht&&"firstInputDelay"===t.R&&this.v.ht.disconnect()},t.prototype.pt=function(t){var i=this;t.V.forEach((function(t){if(i.config.resourceTiming&&i.C("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.kt=function(t){var i=this;t.V.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.g+=s)}}))},t.prototype.W=function(t,i){void 0===i&&(i=3e3),"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:i}):t()},t.prototype.A=function(t){if(!this.h){var i=t.R,s=t.data,n=t.U,e=t.Z,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.O=function(){var t=this;this.T&&this.T.storage&&this.T.storage.estimate().then((function(i){var s={};"usageDetails"in i&&(s=i.usageDetails),t.C("storageEstimate",{storageEstimateQuota:t.G(i.quota),storageEstimateUsage:t.G(i.usage),storageEstimateCaches:t.G(s.caches),storageEstimateIndexedDB:t.G(s.indexedDB),storageEstimatSW:t.G(s.serviceWorkerRegistrations)})}))},t}()}(); | ||
//# sourceMappingURL=perfume.iife.min.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var Perfume=function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.3",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.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.storageEstimateQuota=null,this.storageEstimateUsage=null,this.v=0,this.w=window,this.g=window.performance,this.p=window.navigator,this.T="4g",this.k=!1,this.config=Object.assign({},this.config,t),this._()){if(this.N(),this.P())try{this.I()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.j("navigationTiming",this.C()),this.j("networkInformation",this.O())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.p.hardwareConcurrency&&this.p.hardwareConcurrency<=4)||!!(this.p.deviceMemory&&this.p.deviceMemory<=4)},F:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.T)||!!this.k)},F:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.B(this.o+" started."):(this.u[t]=!0,this.g.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.g.mark("mark_"+t+"_end");var n=this.D(t),e=parseFloat(n.toFixed(2));delete this.u[t],this.M((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={W:t,data:e,R:i,U:n};s.log(r),s.Z(r)}))}else this.B(this.o+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.u[t],this.g.clearMarks&&(this.g.clearMarks("mark_"+t+"_start"),this.g.clearMarks("mark_"+t+"_end"))},t.prototype.A=function(t){return parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.G=function(){this.d.hidden&&(this.s=this.d.hidden)},t.prototype.H=function(t){this.J({K:t,W:"firstInputDelay",V:"duration"}),this.X(),this.Y(),this.$()},t.prototype.Y=function(){this.tt&&(clearTimeout(this.tt),this.tt=void 0,this.j("dataConsumption",this.l))},t.prototype.X=function(){this.m.it&&this.h&&(this.st(this.h,"largestContentfulPaint"),this.m.it.disconnect()),this.m.nt&&this.i>0&&(this.m.nt.takeRecords(),this.st(this.i,"cumulativeLayoutShift",""),this.m.nt.disconnect()),this.m.et&&this.v&&this.st(this.v,"totalBlockingTime")},t.prototype.$=function(){var t=this;setTimeout((function(){t.m.et&&t.v&&t.st(t.v,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.m.et&&(t.v&&t.st(t.v,"totalBlockingTime10S"),t.m.et.disconnect())}),1e4)},t.prototype.rt=function(){this.m.ht=this.ot("first-input",this.H.bind(this))},t.prototype.at=function(){var t=this;this.m.ut=this.ot("paint",(function(i){t.J({K:i,ft:"first-paint",W:"firstPaint",V:"startTime"}),t.J({K:i,ft:"first-contentful-paint",W:"firstContentfulPaint",V:"startTime"})}))},t.prototype.ct=function(){var t=this;this.m.it=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.m.nt=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.vt&&s.value&&(t.i+=s.value)}))},t.prototype.I=function(){this.at(),this.rt(),this.ct(),(this.config.resourceTiming||this.config.dataConsumption)&&this.dt(),this.lt()},t.prototype.dt=function(){var t=this;this.ot("resource",(function(i){t.gt({K:i})})),this.tt=setTimeout((function(){t.Y()}),15e3)},t.prototype.pt=function(){var t=this;this.m.et=this.ot("longtask",(function(i){t.Tt({K:i})})),setTimeout((function(){t.$()}),15e3)},t.prototype._=function(){return this.g&&!!this.g.getEntriesByType&&!!this.g.now&&!!this.g.mark},t.prototype.P=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.g.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=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",storageEstimateQuota:this.storageEstimateQuota,storageEstimateUsage:this.storageEstimateUsage}:{}},t.prototype.C=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.O=function(){if("connection"in this.p){var t=this.p.connection;return"object"!=typeof t?{}:(this.T=t.effectiveType,this.k=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.j=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.M((function(){s.log({W:t,data:i,U:n}),s.Z({W:t,data:i,U:n})}))},t.prototype.st=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.M((function(){n.log({W:i,data:e+" "+s,U:r}),n.Z({W:i,data:e,U: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.U)}},t.prototype.B=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.G.bind(this))},t.prototype.D=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.g.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.J=function(t){var i=this;t.K.forEach((function(s){(!t.ft||t.ft&&s.name===t.ft)&&i.st(s[t.V],t.W),i.m.ut&&"first-contentful-paint"===s.name&&(i.pt(),i.m.ut.disconnect())})),this.m.ht&&"firstInputDelay"===t.W&&this.m.ht.disconnect()},t.prototype.gt=function(t){var i=this;t.K.forEach((function(t){if(i.config.resourceTiming&&i.j("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.Tt=function(t){var i=this;t.K.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.v+=s)}}))},t.prototype.M=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.R,e=t.U,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.N=function(){var t=this;this.p&&this.p.kt&&navigator.kt.estimate().then((function(i){t.storageEstimateQuota="number"==typeof i.wt?t.A(i.wt):null,t.storageEstimateUsage="number"==typeof i._t?t.A(i._t):null}))},t}();module.exports=Perfume; | ||
"use strict";var Perfume=function(){function t(t){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.4",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.h=!1,this.o=0,this.u="Recording already",this.m={},this.v={},this.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.g=0,this.w=window,this.p=window.performance,this.T=window.navigator,this.k="4g",this._=!1,this.config=Object.assign({},this.config,t),this.I()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.C("navigationTiming",this.j()),this.C("networkInformation",this.D()),this.O()}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.T.hardwareConcurrency&&this.T.hardwareConcurrency<=4)||!!(this.T.deviceMemory&&this.T.deviceMemory<=4)},S:!0,B:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.k)||!!this._)},S:!0,B:!0}),t.prototype.start=function(t){this.I()&&(this.m[t]?this.F(this.u+" started."):(this.m[t]=!0,this.p.mark("mark_"+t+"_start"),this.h=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this.I())if(this.m[t]){this.p.mark("mark_"+t+"_end");var n=this.M(t),e=parseFloat(n.toFixed(2));delete this.m[t],this.W((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={R:t,data:e,U:i,Z:n};s.log(r),s.A(r)}))}else this.F(this.u+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.m[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.G=function(t){return"number"!=typeof t?null:parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.H=function(){this.d.hidden&&(this.h=this.d.hidden)},t.prototype.J=function(t){this.K({V:t,R:"firstInputDelay",X:"duration"}),this.Y(),this.$(),this.tt()},t.prototype.$=function(){this.it&&(clearTimeout(this.it),this.it=void 0,this.C("dataConsumption",this.l))},t.prototype.Y=function(){this.v.st&&this.o&&(this.nt(this.o,"largestContentfulPaint"),this.v.st.disconnect()),this.v.et&&this.i>0&&(this.v.et.takeRecords(),this.nt(this.i,"cumulativeLayoutShift",""),this.v.et.disconnect()),this.v.rt&&this.g&&this.nt(this.g,"totalBlockingTime")},t.prototype.tt=function(){var t=this;setTimeout((function(){t.v.rt&&t.g&&t.nt(t.g,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.v.rt&&(t.g&&t.nt(t.g,"totalBlockingTime10S"),t.v.rt.disconnect())}),1e4)},t.prototype.at=function(){this.v.ht=this.ot("first-input",this.J.bind(this))},t.prototype.ut=function(){var t=this;this.v.ft=this.ot("paint",(function(i){t.K({V:i,ct:"first-paint",R:"firstPaint",X:"startTime"}),t.K({V:i,ct:"first-contentful-paint",R:"firstContentfulPaint",X:"startTime"})}))},t.prototype.vt=function(){var t=this;this.v.st=this.ot("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.o=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.v.et=this.ot("layout-shift",(function(i){var s=i.pop();s&&!s.dt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.ut(),this.at(),this.vt(),(this.config.resourceTiming||this.config.dataConsumption)&&this.gt(),this.lt()},t.prototype.gt=function(){var t=this;this.ot("resource",(function(i){t.pt({V:i})})),this.it=setTimeout((function(){t.$()}),15e3)},t.prototype.Tt=function(){var t=this;this.v.rt=this.ot("longtask",(function(i){t.kt({V:i})}))},t.prototype.I=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.p.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=function(){return this.T?{deviceMemory:this.T.deviceMemory?this.T.deviceMemory:0,hardwareConcurrency:this.T.hardwareConcurrency?this.T.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.T?this.T.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.j=function(){if(!this.I())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.D=function(){if("connection"in this.T){var t=this.T.connection;return"object"!=typeof t?{}:(this.k=t.effectiveType,this._=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.C=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.W((function(){s.log({R:t,data:i,Z:n}),s.A({R:t,data:i,Z:n})}))},t.prototype.nt=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.W((function(){n.log({R:i,data:e+" "+s,Z:r}),n.A({R:i,data:e,Z:r})}))}},t.prototype.log=function(t){if(!this.h&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.R+" ","color:#ff6d00;font-size:11px;",t.data,t.Z)}},t.prototype.F=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.H.bind(this))},t.prototype.M=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.p.measure(t,i,s),this.yt(t)},t.prototype.ot=function(t,i){return this.bt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.K=function(t){var i=this;t.V.forEach((function(s){(!t.ct||t.ct&&s.name===t.ct)&&i.nt(s[t.X],t.R),i.v.ft&&"first-contentful-paint"===s.name&&(i.Tt(),i.v.ft.disconnect())})),this.v.ht&&"firstInputDelay"===t.R&&this.v.ht.disconnect()},t.prototype.pt=function(t){var i=this;t.V.forEach((function(t){if(i.config.resourceTiming&&i.C("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.kt=function(t){var i=this;t.V.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.g+=s)}}))},t.prototype.W=function(t,i){void 0===i&&(i=3e3),"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:i}):t()},t.prototype.A=function(t){if(!this.h){var i=t.R,s=t.data,n=t.U,e=t.Z,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.O=function(){var t=this;this.T&&this.T.storage&&this.T.storage.estimate().then((function(i){var s={};"usageDetails"in i&&(s=i.usageDetails),t.C("storageEstimate",{storageEstimateQuota:t.G(i.quota),storageEstimateUsage:t.G(i.usage),storageEstimateCaches:t.G(s.caches),storageEstimateIndexedDB:t.G(s.indexedDB),storageEstimatSW:t.G(s.serviceWorkerRegistrations)})}))},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){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.3",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.o=0,this.h="Recording already",this.u={},this.m={},this.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.storageEstimateQuota=null,this.storageEstimateUsage=null,this.v=0,this.w=window,this.p=window.performance,this.g=window.navigator,this.T="4g",this.k=!1,this.config=Object.assign({},this.config,t),this._()){if(this.N(),this.I())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.j("navigationTiming",this.C()),this.j("networkInformation",this.O())}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.g.hardwareConcurrency&&this.g.hardwareConcurrency<=4)||!!(this.g.deviceMemory&&this.g.deviceMemory<=4)},F:!0,S:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.T)||!!this.k)},F:!0,S:!0}),t.prototype.start=function(t){this._()&&(this.u[t]?this.B(this.h+" started."):(this.u[t]=!0,this.p.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.p.mark("mark_"+t+"_end");var s=this.D(t),e=parseFloat(s.toFixed(2));delete this.u[t],this.M((function(){var s=n.q();s.isLowEndDevice=n.isLowEndDevice,s.isLowEndExperience=n.isLowEndExperience;var r={W:t,data:e,R:i,U:s};n.log(r),n.Z(r)}))}else this.B(this.h+" stopped.")},t.prototype.endPaint=function(t,i){var n=this;setTimeout((function(){n.end(t,i)}))},t.prototype.clear=function(t){delete this.u[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.A=function(t){return parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.G=function(){this.d.hidden&&(this.s=this.d.hidden)},t.prototype.H=function(t){this.J({K:t,W:"firstInputDelay",V:"duration"}),this.X(),this.Y(),this.$()},t.prototype.Y=function(){this.tt&&(clearTimeout(this.tt),this.tt=void 0,this.j("dataConsumption",this.l))},t.prototype.X=function(){this.m.it&&this.o&&(this.nt(this.o,"largestContentfulPaint"),this.m.it.disconnect()),this.m.st&&this.i>0&&(this.m.st.takeRecords(),this.nt(this.i,"cumulativeLayoutShift",""),this.m.st.disconnect()),this.m.et&&this.v&&this.nt(this.v,"totalBlockingTime")},t.prototype.$=function(){var t=this;setTimeout((function(){t.m.et&&t.v&&t.nt(t.v,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.m.et&&(t.v&&t.nt(t.v,"totalBlockingTime10S"),t.m.et.disconnect())}),1e4)},t.prototype.rt=function(){this.m.ot=this.ht("first-input",this.H.bind(this))},t.prototype.at=function(){var t=this;this.m.ut=this.ht("paint",(function(i){t.J({K:i,ft:"first-paint",W:"firstPaint",V:"startTime"}),t.J({K:i,ft:"first-contentful-paint",W:"firstContentfulPaint",V:"startTime"})}))},t.prototype.ct=function(){var t=this;this.m.it=this.ht("largest-contentful-paint",(function(i){var n=i.pop();n&&(t.o=n.renderTime||n.loadTime)}))},t.prototype.lt=function(){var t=this;this.m.st=this.ht("layout-shift",(function(i){var n=i.pop();n&&!n.vt&&n.value&&(t.i+=n.value)}))},t.prototype.P=function(){this.at(),this.rt(),this.ct(),(this.config.resourceTiming||this.config.dataConsumption)&&this.dt(),this.lt()},t.prototype.dt=function(){var t=this;this.ht("resource",(function(i){t.pt({K:i})})),this.tt=setTimeout((function(){t.Y()}),15e3)},t.prototype.gt=function(){var t=this;this.m.et=this.ht("longtask",(function(i){t.Tt({K:i})})),setTimeout((function(){t.$()}),15e3)},t.prototype._=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.I=function(){return"PerformanceObserver"in this.w},t.prototype.yt=function(t){var i=this.p.getEntriesByName(t),n=i[i.length-1];return n&&"measure"===n.entryType?n.duration:-1},t.prototype.q=function(){return this.g?{deviceMemory:this.g.deviceMemory?this.g.deviceMemory:0,hardwareConcurrency:this.g.hardwareConcurrency?this.g.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.g?this.g.serviceWorker.controller?"controlled":"supported":"unsupported",storageEstimateQuota:this.storageEstimateQuota,storageEstimateUsage:this.storageEstimateUsage}:{}},t.prototype.C=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.O=function(){if("connection"in this.g){var t=this.g.connection;return"object"!=typeof t?{}:(this.T=t.effectiveType,this.k=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.j=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.q();s.isLowEndDevice=this.isLowEndDevice,s.isLowEndExperience=this.isLowEndExperience,this.M((function(){n.log({W:t,data:i,U:s}),n.Z({W:t,data:i,U:s})}))},t.prototype.nt=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.M((function(){s.log({W:i,data:e+" "+n,U:r}),s.Z({W:i,data:e,U: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.U)}},t.prototype.B=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.G.bind(this))},t.prototype.D=function(t){var i="mark_"+t+"_start",n="mark_"+t+"_end";return this.p.measure(t,i,n),this.yt(t)},t.prototype.ht=function(t,i){return this.bt=new PerformanceObserver((function(t){var n=t.getEntries();i(n)})),this.bt.observe({type:t,buffered:!0}),this.bt},t.prototype.J=function(t){var i=this;t.K.forEach((function(n){(!t.ft||t.ft&&n.name===t.ft)&&i.nt(n[t.V],t.W),i.m.ut&&"first-contentful-paint"===n.name&&(i.gt(),i.m.ut.disconnect())})),this.m.ot&&"firstInputDelay"===t.W&&this.m.ot.disconnect()},t.prototype.pt=function(t){var i=this;t.K.forEach((function(t){if(i.config.resourceTiming&&i.j("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var n=t.decodedBodySize/1e3;i.l[t.initiatorType]+=n,i.l.total+=n}}))},t.prototype.Tt=function(t){var i=this;t.K.forEach((function(t){if("self"===t.name){var n=t.duration-50;n&&(i.v+=n)}}))},t.prototype.M=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.R,e=t.U,r=s||{};this.config.analyticsTracker({metricName:i,data:n,eventProperties:r,navigatorInformation:e})}},t.prototype.N=function(){var t=this;this.g&&this.g.kt&&navigator.kt.estimate().then((function(i){t.storageEstimateQuota="number"==typeof i.wt?t.A(i.wt):null,t.storageEstimateUsage="number"==typeof i._t?t.A(i._t):null}))},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){if(void 0===t&&(t={}),this.config={dataConsumption:!1,resourceTiming:!1,analyticsTracker:function(t){},logPrefix:"Perfume.js:",logging:!0,maxMeasureTime:15e3},this.t="© 2020 Leonardo Zizzamia",this.version="5.0.0-rc.4",this.c=window.console,this.i=0,this.d=document,this.s=!1,this.o=!1,this.h=0,this.u="Recording already",this.m={},this.v={},this.l={beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0},this.g=0,this.w=window,this.p=window.performance,this.T=window.navigator,this.k="4g",this._=!1,this.config=Object.assign({},this.config,t),this.I()){if(this.N())try{this.P()}catch(t){this.config.logging&&this.c.warn(this.config.logPrefix,t)}this.L(),this.j("navigationTiming",this.C()),this.j("networkInformation",this.D()),this.O()}}return Object.defineProperty(t.prototype,"isLowEndDevice",{get:function(){return!!(this.T.hardwareConcurrency&&this.T.hardwareConcurrency<=4)||!!(this.T.deviceMemory&&this.T.deviceMemory<=4)},S:!0,B:!0}),Object.defineProperty(t.prototype,"isLowEndExperience",{get:function(){return!!this.isLowEndDevice||(!!["slow-2g","2g","3g"].includes(this.k)||!!this._)},S:!0,B:!0}),t.prototype.start=function(t){this.I()&&(this.m[t]?this.F(this.u+" started."):(this.m[t]=!0,this.p.mark("mark_"+t+"_start"),this.o=!1))},t.prototype.end=function(t,i){var s=this;if(void 0===i&&(i={}),this.I())if(this.m[t]){this.p.mark("mark_"+t+"_end");var n=this.M(t),e=parseFloat(n.toFixed(2));delete this.m[t],this.W((function(){var n=s.q();n.isLowEndDevice=s.isLowEndDevice,n.isLowEndExperience=s.isLowEndExperience;var r={R:t,data:e,U:i,Z:n};s.log(r),s.A(r)}))}else this.F(this.u+" stopped.")},t.prototype.endPaint=function(t,i){var s=this;setTimeout((function(){s.end(t,i)}))},t.prototype.clear=function(t){delete this.m[t],this.p.clearMarks&&(this.p.clearMarks("mark_"+t+"_start"),this.p.clearMarks("mark_"+t+"_end"))},t.prototype.G=function(t){return"number"!=typeof t?null:parseFloat((t/Math.pow(1024,2)).toFixed(2))},t.prototype.H=function(){this.d.hidden&&(this.o=this.d.hidden)},t.prototype.J=function(t){this.K({V:t,R:"firstInputDelay",X:"duration"}),this.Y(),this.$(),this.tt()},t.prototype.$=function(){this.it&&(clearTimeout(this.it),this.it=void 0,this.j("dataConsumption",this.l))},t.prototype.Y=function(){this.v.st&&this.h&&(this.nt(this.h,"largestContentfulPaint"),this.v.st.disconnect()),this.v.et&&this.i>0&&(this.v.et.takeRecords(),this.nt(this.i,"cumulativeLayoutShift",""),this.v.et.disconnect()),this.v.rt&&this.g&&this.nt(this.g,"totalBlockingTime")},t.prototype.tt=function(){var t=this;setTimeout((function(){t.v.rt&&t.g&&t.nt(t.g,"totalBlockingTime5S")}),5e3),setTimeout((function(){t.v.rt&&(t.g&&t.nt(t.g,"totalBlockingTime10S"),t.v.rt.disconnect())}),1e4)},t.prototype.ot=function(){this.v.ht=this.at("first-input",this.J.bind(this))},t.prototype.ut=function(){var t=this;this.v.ft=this.at("paint",(function(i){t.K({V:i,ct:"first-paint",R:"firstPaint",X:"startTime"}),t.K({V:i,ct:"first-contentful-paint",R:"firstContentfulPaint",X:"startTime"})}))},t.prototype.vt=function(){var t=this;this.v.st=this.at("largest-contentful-paint",(function(i){var s=i.pop();s&&(t.h=s.renderTime||s.loadTime)}))},t.prototype.lt=function(){var t=this;this.v.et=this.at("layout-shift",(function(i){var s=i.pop();s&&!s.dt&&s.value&&(t.i+=s.value)}))},t.prototype.P=function(){this.ut(),this.ot(),this.vt(),(this.config.resourceTiming||this.config.dataConsumption)&&this.gt(),this.lt()},t.prototype.gt=function(){var t=this;this.at("resource",(function(i){t.pt({V:i})})),this.it=setTimeout((function(){t.$()}),15e3)},t.prototype.Tt=function(){var t=this;this.v.rt=this.at("longtask",(function(i){t.yt({V:i})}))},t.prototype.I=function(){return this.p&&!!this.p.getEntriesByType&&!!this.p.now&&!!this.p.mark},t.prototype.N=function(){return"PerformanceObserver"in this.w},t.prototype.bt=function(t){var i=this.p.getEntriesByName(t),s=i[i.length-1];return s&&"measure"===s.entryType?s.duration:-1},t.prototype.q=function(){return this.T?{deviceMemory:this.T.deviceMemory?this.T.deviceMemory:0,hardwareConcurrency:this.T.hardwareConcurrency?this.T.hardwareConcurrency:0,serviceWorkerStatus:"serviceWorker"in this.T?this.T.serviceWorker.controller?"controlled":"supported":"unsupported"}:{}},t.prototype.C=function(){if(!this.I())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.D=function(){if("connection"in this.T){var t=this.T.connection;return"object"!=typeof t?{}:(this.k=t.effectiveType,this._=!!t.saveData,{downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData})}return{}},t.prototype.j=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.q();n.isLowEndDevice=this.isLowEndDevice,n.isLowEndExperience=this.isLowEndExperience,this.W((function(){s.log({R:t,data:i,Z:n}),s.A({R:t,data:i,Z:n})}))},t.prototype.nt=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.q();r.isLowEndDevice=this.isLowEndDevice,r.isLowEndExperience=this.isLowEndExperience,this.W((function(){n.log({R:i,data:e+" "+s,Z:r}),n.A({R:i,data:e,Z:r})}))}},t.prototype.log=function(t){if(!this.o&&this.config.logging){this.c.log("%c "+this.config.logPrefix+" "+t.R+" ","color:#ff6d00;font-size:11px;",t.data,t.Z)}},t.prototype.F=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.H.bind(this))},t.prototype.M=function(t){var i="mark_"+t+"_start",s="mark_"+t+"_end";return this.p.measure(t,i,s),this.bt(t)},t.prototype.at=function(t,i){return this.kt=new PerformanceObserver((function(t){var s=t.getEntries();i(s)})),this.kt.observe({type:t,buffered:!0}),this.kt},t.prototype.K=function(t){var i=this;t.V.forEach((function(s){(!t.ct||t.ct&&s.name===t.ct)&&i.nt(s[t.X],t.R),i.v.ft&&"first-contentful-paint"===s.name&&(i.Tt(),i.v.ft.disconnect())})),this.v.ht&&"firstInputDelay"===t.R&&this.v.ht.disconnect()},t.prototype.pt=function(t){var i=this;t.V.forEach((function(t){if(i.config.resourceTiming&&i.j("resourceTiming",t),i.config.dataConsumption&&t.decodedBodySize&&t.initiatorType){var s=t.decodedBodySize/1e3;i.l[t.initiatorType]+=s,i.l.total+=s}}))},t.prototype.yt=function(t){var i=this;t.V.forEach((function(t){if("self"===t.name){var s=t.duration-50;s&&(i.g+=s)}}))},t.prototype.W=function(t,i){void 0===i&&(i=3e3),"requestIdleCallback"in this.w?this.w.requestIdleCallback(t,{timeout:i}):t()},t.prototype.A=function(t){if(!this.o){var i=t.R,s=t.data,n=t.U,e=t.Z,r=n||{};this.config.analyticsTracker({metricName:i,data:s,eventProperties:r,navigatorInformation:e})}},t.prototype.O=function(){var t=this;this.T&&this.T.storage&&this.T.storage.estimate().then((function(i){var s={};"usageDetails"in i&&(s=i.usageDetails),t.j("storageEstimate",{storageEstimateQuota:t.G(i.quota),storageEstimateUsage:t.G(i.usage),storageEstimateCaches:t.G(s.caches),storageEstimateIndexedDB:t.G(s.indexedDB),storageEstimatSW:t.G(s.serviceWorkerRegistrations)})}))},t}()})); | ||
//# sourceMappingURL=perfume.umd.min.js.map |
/*! | ||
* Perfume.js v5.0.0-rc.3 (http://zizzamia.github.io/perfume) | ||
* Perfume.js v5.0.0-rc.4 (http://zizzamia.github.io/perfume) | ||
* Copyright 2020 Leonardo Zizzamia (https://github.com/Zizzamia/perfume.js/graphs/contributors) | ||
@@ -45,4 +45,2 @@ * Licensed under MIT (https://github.com/Zizzamia/perfume.js/blob/master/LICENSE) | ||
serviceWorkerStatus?: 'controlled' | 'supported' | 'unsupported'; | ||
storageEstimateQuota?: number | null; | ||
storageEstimateUsage?: number | null; | ||
} | ||
@@ -118,2 +116,3 @@ export interface IPerfObservers { | ||
private dataConsumptionTimeout; | ||
private hasSetStorageEstimate; | ||
private isHidden; | ||
@@ -126,4 +125,2 @@ private lcpDuration; | ||
private perfResourceTiming; | ||
private storageEstimateQuota; | ||
private storageEstimateUsage; | ||
private totalBlockingTimeScore; | ||
@@ -202,4 +199,2 @@ private w; | ||
* - unsupported: the user's browser does not support service worker | ||
* 4. Storage quota | ||
* 5. Storage usage | ||
*/ | ||
@@ -260,4 +255,4 @@ private getNavigatorInfo; | ||
*/ | ||
private setStorageEstimate; | ||
private initStorageEstimate; | ||
} | ||
export {}; |
{ | ||
"name": "perfume.js", | ||
"version": "5.0.0-rc.3", | ||
"version": "5.0.0-rc.4", | ||
"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.", | ||
@@ -82,6 +82,6 @@ "keywords": [ | ||
"global": { | ||
"branches": 87, | ||
"branches": 85, | ||
"functions": 100, | ||
"lines": 96, | ||
"statements": 96 | ||
"lines": 95, | ||
"statements": 95 | ||
} | ||
@@ -88,0 +88,0 @@ }, |
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
294249
1634