From d83ad04c76d6cf4a96d072ca678977712cc07c14 Mon Sep 17 00:00:00 2001 From: Karina Thomas Date: Mon, 2 Sep 2024 19:01:25 +0100 Subject: [PATCH 1/3] Remove `fid` support --- src/index.js | 3 +-- src/index.test.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/index.js b/src/index.js index 182528f..71e1493 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ const webVitalsBase = { url: 'current-page-url', }; -const vitals = { cls: null, fid: null, lcp: null, fcp: null, ttfb: null }; +const vitals = { cls: null, lcp: null, fcp: null, ttfb: null }; const deviceMetrics = { device_mem: null, device_cpu: null, @@ -136,7 +136,6 @@ const useWebVitals = ({ deviceMemory, }); onCLS(updateWebVitals, { reportAllChanges: true }); - onFID(updateWebVitals); onLCP(updateWebVitals, { reportAllChanges: true }); onFCP(updateWebVitals); onTTFB(updateWebVitals); diff --git a/src/index.test.js b/src/index.test.js index e28ec73..aa3d2e6 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -16,11 +16,10 @@ const mockVitalsGet = (name, value) => reportHandler => { }; webVitals.onCLS.mockImplementation(mockVitalsGet('CLS', 1)); -webVitals.onFID.mockImplementation(mockVitalsGet('FID', 2)); -webVitals.onLCP.mockImplementation(mockVitalsGet('LCP', 3)); -webVitals.onFCP.mockImplementation(mockVitalsGet('FCP', 4)); -webVitals.onTTFB.mockImplementation(mockVitalsGet('TTFB', 5)); -webVitals.onINP.mockImplementation(mockVitalsGet('INP', 6)); +webVitals.onLCP.mockImplementation(mockVitalsGet('LCP', 2)); +webVitals.onFCP.mockImplementation(mockVitalsGet('FCP', 3)); +webVitals.onTTFB.mockImplementation(mockVitalsGet('TTFB', 4)); +webVitals.onINP.mockImplementation(mockVitalsGet('INP', 5)); let eventListeners = {}; @@ -79,7 +78,6 @@ describe('useWebVitals', () => { renderHook(() => useWebVitals({ enabled })); expect(webVitals.onCLS).toHaveBeenCalled(); - expect(webVitals.onFID).toHaveBeenCalled(); expect(webVitals.onLCP).toHaveBeenCalled(); expect(webVitals.onFCP).toHaveBeenCalled(); expect(webVitals.onTTFB).toHaveBeenCalled(); @@ -181,7 +179,6 @@ describe('useWebVitals', () => { renderHook(() => useWebVitals({ enabled, reportingEndpoint })); expect(webVitals.onCLS).toHaveBeenCalled(); - expect(webVitals.onFID).toHaveBeenCalled(); expect(webVitals.onLCP).toHaveBeenCalled(); expect(webVitals.onFCP).toHaveBeenCalled(); expect(webVitals.onTTFB).toHaveBeenCalled(); @@ -194,11 +191,10 @@ describe('useWebVitals', () => { type: 'web-vitals', body: expect.objectContaining({ cls: 1, - fid: 2, - lcp: 3, - fcp: 4, - ttfb: 5, - inp: 6, + lcp: 2, + fcp: 3, + ttfb: 4, + inp: 5, }), }), ]; From 39f39ab4214c92fc7c29cfc6995a11d43966001f Mon Sep 17 00:00:00 2001 From: Karina Thomas Date: Mon, 2 Sep 2024 19:04:07 +0100 Subject: [PATCH 2/3] Include `inp` in list of vitals to collect --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 71e1493..cf18459 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ const webVitalsBase = { url: 'current-page-url', }; -const vitals = { cls: null, lcp: null, fcp: null, ttfb: null }; +const vitals = { cls: null, lcp: null, fcp: null, ttfb: null, inp: null }; const deviceMetrics = { device_mem: null, device_cpu: null, From f35514c88cd5efd5ed03ed65276cdce1d85b5d0d Mon Sep 17 00:00:00 2001 From: Karina Thomas Date: Mon, 2 Sep 2024 19:05:05 +0100 Subject: [PATCH 3/3] Minor package upgrade as it is removing a metric which is no longer supported --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93ff565..c3c1cb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bbc/web-vitals", - "version": "2.3.1", + "version": "2.4.0", "main": "dist/index.js", "module": "esm/index.js", "exports": {