From 45bc041389228e43d6845424131292e60934f424 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Thu, 15 Jul 2021 16:05:47 +0530 Subject: Initial commit --- src/reportWebVitals.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/reportWebVitals.ts (limited to 'src/reportWebVitals.ts') diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts new file mode 100644 index 0000000..49a2a16 --- /dev/null +++ b/src/reportWebVitals.ts @@ -0,0 +1,15 @@ +import { ReportHandler } from 'web-vitals'; + +const reportWebVitals = (onPerfEntry?: ReportHandler) => { + if (onPerfEntry && onPerfEntry instanceof Function) { + import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(onPerfEntry); + getFID(onPerfEntry); + getFCP(onPerfEntry); + getLCP(onPerfEntry); + getTTFB(onPerfEntry); + }); + } +}; + +export default reportWebVitals; -- cgit v1.2.3