I’m trying to connect Sentry to NextJS/React app. So far I’ve successfully connected from client (React) via @sentry/browser, but if I try to connect from server-side (NextJS + Express) via @sentry/node I get an error about missing dependency:
./node_modules/@sentry/node/dist/integrations/console.js Module not found: Can't resolve 'console' in '/node_modules/@sentry/node/dist/int egrations'
As a workaround I tried to install console dependency manually but another one occured:
./node_modules/@sentry/node/dist/transports/base.js Module not found: Can't resolve 'fs' in '/node_modules/@sentry/node/dist/transpor ts'
Thanks for the reply, I think you’ve brought me closer to the solution.
I am trying to connect Sentry in apollo-client via onError. This client is only called from redux-sagas triggered by action from getInitialProps - this way I’d thought that it is still server side - so I import @sentry/node which resolves into “fs” error above. If I import @sentry/browser this error pops: Sentry Logger [Error]: ReferenceError: XMLHttpRequest is not defined
Another weird thing is that if I require @sentry/node only if process.browser is false, it gives me same error as for importing @sentry/browser: Sentry Logger [Error]: ReferenceError: XMLHttpRequest is not defined but this part of code only loads one time and it is only server-side.