You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How are you deploying your application? (if relevant)
No response
Describe the Bug
calling reportWebVitals when having google analytics setup using with-google-analytics results in Next.js-hydration event getting triggered BEFORE gtag is initialized.
This could be problematic in production if someone is just assuming gtag is always defined when reporting on web vitals.
Expected Behavior
When having google analytics setup using the with-google-analytics example, I would expect gtag to be defined for all events before triggering reportWebVitals.
…40645)
Next.js-hydration now triggered after gtag is initialized. Fixed by adding _document.js and appropriate script elements.
---
## Documentation / Examples
- [X] Related issues linked using fixes#40410
- [X] Make sure the linting passes by running `pnpm lint`
- [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Next.js-hydration now triggered after gtag is initialized.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Verify canary release
Provide environment information
Which example does this report relate to?
with-google-analytics
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
calling
reportWebVitals
when having google analytics setup usingwith-google-analytics
results inNext.js-hydration
event getting triggered BEFORE gtag is initialized.This could be problematic in production if someone is just assuming
gtag
is always defined when reporting on web vitals.Expected Behavior
When having google analytics setup using the
with-google-analytics
example, I would expectgtag
to be defined for all events before triggeringreportWebVitals
.To Reproduce
Here is a link to reproduce: https://stackblitz.com/edit/nextjs-rnaue8?file=pages%2F_app.js,.env.local.example,lib%2Fgtag.js,pages%2Findex.js
The text was updated successfully, but these errors were encountered: