Skip to content

Commit ac7a2bb

Browse files
authored
chore: Update deprecated web vitals library methods (#293)
1 parent 534c4f6 commit ac7a2bb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"prepare": "husky install"
6161
},
6262
"devDependencies": {
63+
"@aws-sdk/client-rum": "^3.76.0",
6364
"@babel/plugin-transform-runtime": "^7.16.0",
6465
"@babel/preset-env": "~7.6.3",
6566
"@playwright/test": "^1.21.1",
@@ -114,7 +115,6 @@
114115
},
115116
"dependencies": {
116117
"@aws-crypto/sha256-js": "^2.0.2",
117-
"@aws-sdk/client-rum": "^3.76.0",
118118
"@aws-sdk/fetch-http-handler": "^3.36.0",
119119
"@aws-sdk/protocol-http": "^3.36.0",
120120
"@aws-sdk/signature-v4": "^3.36.0",

src/plugins/event-plugins/WebVitalsPlugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { InternalPlugin } from '../InternalPlugin';
22
import { LargestContentfulPaintEvent } from '../../events/largest-contentful-paint-event';
33
import { FirstInputDelayEvent } from '../../events/first-input-delay-event';
44
import { CumulativeLayoutShiftEvent } from '../../events/cumulative-layout-shift-event';
5-
import { getCLS, getFID, getLCP, Metric } from 'web-vitals';
5+
import { Metric, onCLS, onFID, onLCP } from 'web-vitals';
66
import {
77
LCP_EVENT_TYPE,
88
FID_EVENT_TYPE,
@@ -37,8 +37,8 @@ export class WebVitalsPlugin extends InternalPlugin {
3737
}
3838

3939
protected onload(): void {
40-
getLCP((data) => this.getWebVitalData(data, LCP_EVENT_TYPE));
41-
getFID((data) => this.getWebVitalData(data, FID_EVENT_TYPE));
42-
getCLS((data) => this.getWebVitalData(data, CLS_EVENT_TYPE));
40+
onLCP((data) => this.getWebVitalData(data, LCP_EVENT_TYPE));
41+
onFID((data) => this.getWebVitalData(data, FID_EVENT_TYPE));
42+
onCLS((data) => this.getWebVitalData(data, CLS_EVENT_TYPE));
4343
}
4444
}

src/plugins/event-plugins/__tests__/WebVitalsPlugin.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ const mockCLSData = {
2929

3030
jest.mock('web-vitals', () => {
3131
return {
32-
getLCP: jest
32+
onLCP: jest
3333
.fn()
3434
.mockImplementation((callback) =>
3535
callback(mockLCPData, LCP_EVENT_TYPE)
3636
),
37-
getFID: jest
37+
onFID: jest
3838
.fn()
3939
.mockImplementation((callback) =>
4040
callback(mockFIDData, FID_EVENT_TYPE)
4141
),
42-
getCLS: jest
42+
onCLS: jest
4343
.fn()
4444
.mockImplementation((callback) =>
4545
callback(mockCLSData, CLS_EVENT_TYPE)

0 commit comments

Comments
 (0)