@aller/blink-labrador
Advanced tools
Comparing version 8.24.10-alpha.0 to 8.24.11-alpha.0
@@ -210,5 +210,6 @@ "use strict"; | ||
var webVitals = vitalsTracker.getAllMetrics(); | ||
var now = vitalsTracker.now(); | ||
window.setTimeout(function () { | ||
console.log('Web vitals from timeout', webVitals); | ||
if (webVitals) { | ||
webVitals.visitDurationAtSend = now; | ||
_this_1.blink.webVitals({ webVitals: webVitals }); | ||
@@ -221,4 +222,4 @@ // start another measurement for sending with the hidden state | ||
if (document.visibilityState === 'hidden') { | ||
console.log('Web vitals from documenthidden callback', webVitals); | ||
if (webVitals) { | ||
webVitals.visitDurationAtSend = now; | ||
_this_1.blink.webVitals({ webVitals: webVitals }); | ||
@@ -225,0 +226,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import type { Metric } from 'web-vitals'; | ||
type LogMetric = { | ||
@@ -16,2 +17,3 @@ value: number; | ||
webVitalsReport: WebVitalsReport; | ||
mapMetric(metric: Metric): LogMetric | undefined; | ||
cls(): void; | ||
@@ -24,4 +26,5 @@ ttfb(): void; | ||
get performanceAPISupported(): boolean; | ||
getAllMetrics(): WebVitalsReport | undefined; | ||
now(): number; | ||
getAllMetrics(now?: number): WebVitalsReport | undefined; | ||
} | ||
export default ChromeWebVitals; |
@@ -19,31 +19,37 @@ "use strict"; | ||
} | ||
ChromeWebVitals.prototype.mapMetric = function (metric) { | ||
var report = this.webVitalsReport[metric.name]; | ||
if (!report) | ||
return; | ||
return formatCWVreport(metric); | ||
}; | ||
ChromeWebVitals.prototype.cls = function () { | ||
var _this = this; | ||
return (0, attribution_1.onCLS)(function (report) { | ||
_this.webVitalsReport[report.name] = formatCWVreport(report); | ||
}, { reportAllChanges: true }); | ||
return (0, attribution_1.onCLS)(function (metric) { return _this.mapMetric(metric); }, { | ||
reportAllChanges: true, | ||
}); | ||
}; | ||
ChromeWebVitals.prototype.ttfb = function () { | ||
var _this = this; | ||
return (0, web_vitals_1.onTTFB)(function (report) { | ||
_this.webVitalsReport[report.name] = formatCWVreport(report); | ||
}, { reportAllChanges: true }); | ||
return (0, web_vitals_1.onTTFB)(function (metric) { return _this.mapMetric(metric); }, { | ||
reportAllChanges: true, | ||
}); | ||
}; | ||
ChromeWebVitals.prototype.lcp = function () { | ||
var _this = this; | ||
return (0, attribution_1.onLCP)(function (report) { | ||
_this.webVitalsReport[report.name] = formatCWVreport(report); | ||
}, { reportAllChanges: true }); | ||
return (0, attribution_1.onLCP)(function (metric) { return _this.mapMetric(metric); }, { | ||
reportAllChanges: true, | ||
}); | ||
}; | ||
ChromeWebVitals.prototype.inp = function () { | ||
var _this = this; | ||
return (0, web_vitals_1.onINP)(function (report) { | ||
_this.webVitalsReport[report.name] = formatCWVreport(report); | ||
}, { reportAllChanges: true }); | ||
return (0, web_vitals_1.onINP)(function (metric) { return _this.mapMetric(metric); }, { | ||
reportAllChanges: true, | ||
}); | ||
}; | ||
ChromeWebVitals.prototype.fcp = function () { | ||
var _this = this; | ||
return (0, web_vitals_1.onFCP)(function (report) { | ||
_this.webVitalsReport[report.name] = formatCWVreport(report); | ||
}, { reportAllChanges: true }); | ||
return (0, web_vitals_1.onFCP)(function (metric) { return _this.mapMetric(metric); }, { | ||
reportAllChanges: true, | ||
}); | ||
}; | ||
@@ -63,3 +69,8 @@ ChromeWebVitals.prototype.fid = function () { | ||
}); | ||
ChromeWebVitals.prototype.getAllMetrics = function () { | ||
ChromeWebVitals.prototype.now = function () { | ||
if (typeof performance === 'undefined') | ||
return 0; | ||
return roundToPrec(performance.now(), 0); | ||
}; | ||
ChromeWebVitals.prototype.getAllMetrics = function (now) { | ||
if (!this.performanceAPISupported) | ||
@@ -73,4 +84,3 @@ return; | ||
this.fid(); | ||
this.webVitalsReport.visitDurationAtSend = now(); | ||
console.log('webvitalsreport in chrome-web-vitals class getAllMetrics', this.webVitalsReport); | ||
this.webVitalsReport.visitDurationAtSend = now || 0; | ||
return this.webVitalsReport; | ||
@@ -80,7 +90,2 @@ }; | ||
}()); | ||
function now() { | ||
if (typeof performance === 'undefined') | ||
return 0; | ||
return roundToPrec(performance.now(), 0); | ||
} | ||
function roundToPrec(val, precision) { | ||
@@ -87,0 +92,0 @@ if (precision === void 0) { precision = 0; } |
{ | ||
"name": "@aller/blink-labrador", | ||
"version": "8.24.10-alpha.0", | ||
"version": "8.24.11-alpha.0", | ||
"description": "Library for using blink on Labrador", | ||
@@ -76,3 +76,3 @@ "main": "lib/main.js", | ||
"dependencies": { | ||
"@aller/blink": "^8.24.10-alpha.0", | ||
"@aller/blink": "^8.24.11-alpha.0", | ||
"@soldotno/aller-in-view": "^3.0.2", | ||
@@ -96,3 +96,3 @@ "react": "^16.11.0", | ||
}, | ||
"gitHead": "5862609b742aa22570f7f74d855f0b0898244be1" | ||
"gitHead": "7e9c79d9ccbf28a2a10ab129b9a23e40099a4353" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
469075
6328