Skip to content

Commit c89ec7e

Browse files
fix(deps): update dependency web-vitals to v5 (#2023)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Xiao Peng <xiao_peng0202@hotmail.com>
1 parent 0c4f0bd commit c89ec7e

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"vite": "^5.2.8",
5151
"vite-plugin-istanbul": "6.0.0",
5252
"vitest": "^3.0.0",
53-
"web-vitals": "^3.3.1"
53+
"web-vitals": "^5.0.3"
5454
},
5555
"devDependencies": {
5656
"@cypress/code-coverage": "^3.12.1",

frontend/src/reportWebVitals.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import { ReportHandler } from 'web-vitals';
1+
import {
2+
onCLS, onFCP, onINP, onLCP, onTTFB
3+
} from 'web-vitals';
4+
5+
type ReportHandler = (metric: {
6+
name: string;
7+
value: number;
8+
delta: number;
9+
id: string;
10+
entries: PerformanceEntry[];
11+
navigationType?: string;
12+
}) => void;
213

314
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4-
if (onPerfEntry && onPerfEntry instanceof Function) {
5-
import('web-vitals').then(({
6-
getCLS,
7-
getFID,
8-
getFCP,
9-
getLCP,
10-
getTTFB
11-
}) => {
12-
getCLS(onPerfEntry);
13-
getFID(onPerfEntry);
14-
getFCP(onPerfEntry);
15-
getLCP(onPerfEntry);
16-
getTTFB(onPerfEntry);
17-
});
15+
if (onPerfEntry && typeof onPerfEntry === 'function') {
16+
onCLS(onPerfEntry);
17+
onINP(onPerfEntry);
18+
onFCP(onPerfEntry);
19+
onLCP(onPerfEntry);
20+
onTTFB(onPerfEntry);
1821
}
1922
};
2023

0 commit comments

Comments
 (0)