Amplitude-TypeScript
Amplitude-TypeScript copied to clipboard
fix(analytics-browser): prevent error being thrown when server-side rendering
Summary
Fixes #710 - I'm not sure why, but this library gets pulled into the SSR part of my next.js project. Likely a treeshaking issue. It then throws and error because navigtator is missing.
Checklist
- [X] Does your PR title have the correct title format?
- Does your PR have a breaking change?: No
Looks okay to me, hopefully we can merge these changes so it will be helpful to utilize them soon
@izaaz Any chance of getting this merged?
@izaaz I've added some extra places where SSR causes issues
@johnf - created a new PR for this https://github.com/amplitude/Amplitude-TypeScript/pull/876
For the other two plugin changes, we've already made changes to use getGlobalScope()?.addEventListener
instead of window.addEventListener
which should have fixed those problems already. Can you please take a look at the other PR and approve it if it looks good?
Closing in favour of #876
@johnf this should be now available in version 2.11.7. Please let me know if you run into issues