Skip to content

Commit

Permalink
Remove fid support
Browse files Browse the repository at this point in the history
  • Loading branch information
karinathomasbbc committed Sep 2, 2024
1 parent 8ab7495 commit d83ad04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
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 };
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

0 comments on commit d83ad04

Please sign in to comment.