import type { AppProps , NextWebVitalsMetric } from 'next/app' ; import { useRouter } from 'next/router' ; import { useEffect } from 'react' ; import * as gtag from '@/lib/gtag' ; import '../styles.css' ; function PokeServerless ( { Component , pageProps } ) { const router = useRouter ( ) ; useEffect ( ( ) => { const handleRouteChange = ( url ) => { gtag . pageview ( url ) ; } ; router . events . on ( 'routeChangeComplete' , handleRouteChange ) ; return ( ) => { router . events . off ( 'routeChangeComplete' , handleRouteChange ) ; } ; } , [ router . events ] ) ; return < Component { ... pageProps } / > ; } export function reportWebVitals ( metric ) { if ( window ) { window . gtag ( 'event' , metric . name , { event_category : metric . label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric' , value : Math . round ( metric . name === 'CLS' ? metric . value * 1000 : metric . value ) , event_label : metric . id , non_interaction : true , } ) ; } } export default PokeServerless ;