From f846326bb3878eb936e6dc271fdb8491b96ddeb0 Mon Sep 17 00:00:00 2001 From: SuperOleg39 Date: Tue, 21 Feb 2023 04:30:39 +0300 Subject: [PATCH] feat: handle TTFB from web-vitals without transform (#221) --- package-lock.json | 4 ++-- src/observe.ts | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4df5722..e9752ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "perfume.js", - "version": "8.2.0", + "version": "8.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "perfume.js", - "version": "8.2.0", + "version": "8.3.0", "license": "MIT", "dependencies": { "web-vitals": "^3.1.0" diff --git a/src/observe.ts b/src/observe.ts index 4d19b47..de3c8f8 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -14,14 +14,11 @@ import { po } from './performanceObserver'; import { initResourceTiming } from './resourceTiming'; export const initPerformanceObserver = (): void => { - // @ts-ignore onTTFB(report => { - // Calculate the request time by subtracting from TTFB - // everything that happened prior to the request starting. - // @ts-ignore - report.value = report.value - report.entries[0].requestStart; - // @ts-ignore - logMetric(report); + if (report.value > 0) { + // @ts-ignore + logMetric(report); + } }, config.reportOptions.ttfb); // @ts-ignore onCLS(report => logMetric(report), config.reportOptions.cls);