Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fid web vital as it is no longer supported #39

Draft
wants to merge 3 commits into
base: latest
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/web-vitals",
"version": "2.3.1",
"version": "2.4.0",
Copy link
Contributor Author

@karinathomasbbc karinathomasbbc Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be major since we're dropping support for a core metric? (Second opinions needed!)

"main": "dist/index.js",
"module": "esm/index.js",
"exports": {
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, inp: null };
const deviceMetrics = {
device_mem: null,
device_cpu: null,
Expand Down Expand Up @@ -136,7 +136,6 @@ const useWebVitals = ({
deviceMemory,
});
onCLS(updateWebVitals, { reportAllChanges: true });
onFID(updateWebVitals);
onLCP(updateWebVitals, { reportAllChanges: true });
onFCP(updateWebVitals);
onTTFB(updateWebVitals);
Expand Down
20 changes: 8 additions & 12 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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,
}),
}),
];
Expand Down