#How can I enable Sentry only in production env?

4 messages · Page 1 of 1 (latest)

errant arch
#

I want to disable Sentry completely, I was thinking of using the following condition if (process.env.NODE_ENV === 'production'), as the docs say: https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#enabled

but I'm not sure how to disable the functions found in the instrumentation.ts files.

export const onRequestError = Sentry.captureRequestError; (server side)

export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; (client side)

Any suggestions? how do you disable Sentry? I'm new to using Sentry

calm night
#

I have a similar question.

In our project, we need to disable Sentry for local app builds. Also, we use Next.js tunnelling feature for bypassing blockers.

As for now, as a workaround, we just don't populate the value of Sentry DSN, which is required for Sentry to work. As a drawback, all tunnelled Sentry request just fail with 401, and no reports are sent. But if there is a more elegant solution, it would be nice to know about it.

lone void
#

i ran a few test runs in my nextjs app and did not run into errors when adding enabled:false to all inits, which is what we expect to happen.
@ionic copper do you have additional information on keeping the exported functions Raky mentions when the SDK is disabled?

ionic copper
#

Those functions should not do anything if the sentry sdk has not been initialized, but maybe we can make that more clear. @latent gust do you have any thoughts?