From 753d008cfd28f5e46a542031207b2dc5a485f1f3 Mon Sep 17 00:00:00 2001 From: ekremney Date: Thu, 18 Apr 2024 11:31:33 +0200 Subject: [PATCH] feat: cwv-ttfb is measured manually --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index 8a909cd..6a80b23 100644 --- a/src/index.js +++ b/src/index.js @@ -103,6 +103,11 @@ sampleRUM.drain('cwv', (() => { storeCWV({ name: 'LCP', value: entry.renderTime, entries: [entry] }); }); + registerPerformanceObserver('navigation', (entries) => { + const entry = entries.pop(); + storeCWV({ name: 'TTFB', value: entry.responseStart }); + }); + const cwvScript = new URL('.rum/web-vitals/dist/web-vitals.iife.js', sampleRUM.baseURL).href; if (document.querySelector(`script[src="${cwvScript}"]`)) { // web vitals script has been loaded already