Skip to content

Commit

Permalink
web vitals: rework
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Nov 3, 2023
1 parent 6342152 commit 8b9ebbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextWebVitalsMetric } from 'next/app';

export function reportWebVitals(metric: NextWebVitalsMetric): void {
export function trackWebVitals(metric: NextWebVitalsMetric): void {
console.debug('web vitals', metric);
}
5 changes: 3 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { UserPrivate } from 'data/graphql-generated';
import { UserProvider } from '@auth0/nextjs-auth0/client';
import clientHealthCheck from 'app/clientHealthCheck';
import { useRouter } from 'next/router';
import { trackWebVitals } from 'app/reportWebVitals';
import { useReportWebVitals } from 'next/web-vitals';

// If loading a variable font, you don't need to specify the font weight
const pressStart2P = Press_Start_2P({
Expand All @@ -39,8 +41,6 @@ const marckScript = Marck_Script({
display: 'swap',
});

export { reportWebVitals } from 'app/reportWebVitals';

// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();

Expand Down Expand Up @@ -68,6 +68,7 @@ function MyApp({ Component, emotionCache = clientSideEmotionCache, pageProps }:
const { locale = 'en', defaultLocale = 'en' } = useRouter();
const apolloClient = useApollo(pageProps);
const [currentUser, setCurrentUser] = useState<UserPrivate>();
useReportWebVitals(trackWebVitals);

useEffect(() => {
// Upon starting the app, kick off a client health check which runs periodically.
Expand Down

0 comments on commit 8b9ebbf

Please sign in to comment.