next/app#NextWebVitalsMetric TypeScript Examples
The following examples show how to use
next/app#NextWebVitalsMetric.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: _app.tsx From crosshare with GNU Affero General Public License v3.0 | 6 votes |
export function reportWebVitals(metric: NextWebVitalsMetric) {
console.log(metric);
if (
process.env.NODE_ENV !== 'production' &&
metric.name === 'CLS' &&
metric.value
) {
console.error('NONZERO CLS ', metric.value);
}
gtag.event({
action: metric.name,
category:
metric.label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric',
label: metric.id,
value: Math.round(
metric.name === 'CLS' ? metric.value * 1000 : metric.value
),
nonInteraction: true,
});
}