-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segment broke with next js 13.5.2 #969
Comments
Thanks for opening an issue @AbdelrhmanX7. We made some changes that I think likely surfaced this issue recently, but It does looks like you're calling From 1.58.0 onward, I think it's extra important that you ensure you only call For more info, check out these next.js examples: |
I downgrade to segment v1.51 and everything works fine now and i am already using segment analytics.track in a client side and this issue just appeared from nothing and i don't even know what is the main reason for this issue everything was fine and suddenly everything stopped working |
"document is not defined" means that it's being called in a server context. Please see those next.js examples I posted in my previous comment. Older versions of this library may have seemed like they "worked" because this error didn't bubble up in your code, but calling track in a server context is never something we support, and can even be dangerous if it can result in fatal unhandled promises that could even crash future node app inadvertently. It's actually better to fail loudly. Our position is basically that calling analytics methods in a server context represents a bug in one's code, so it's up to ths owner to fix it. Usually it's just following established patterns. e.g. call track in a useEffect hook, check for the existence of "window", etc. See Next.js examples. |
i got this issue while i am using yarn build with next js 13.5.2
The text was updated successfully, but these errors were encountered: