I'd like to disable sending errors to Sentry in my dev environment. However I'd like to keep all of Sentry's error handling intact (besides sending the errors to Sentry's backend) so that I can test it in dev. For example, I have a custom event processor added to Sentry with Sentry.addGlobalEventProcessor
and I'd like that to continue running (so I can test it).
Things I've tried:
enabled: false
. This does not work because it entirely disables Sentry (event processors don't fire anymore):
Sentry.init({
dsn: '...',
enabled: false,
});
sampleRate: 0
. This effectively does the same thing as setting enabled: false
:
Sentry.init({
dsn: '...',
enabled: true,
sampleRate: 0,
});
dsn: ''
. Same as above, Sentry simple stops doing anything:
Sentry.init({
dsn: '',
enabled: true,
});
Unless someone has a better solution, it looks like the easiest way to accomplish this is to always return null
in beforeSend
and beforeSendTransaction
:
Sentry.init({
dsn: '...',
enabled: true,
beforeSend() {
return null;
},
beforeSendTransaction() {
return null;
},
});
This maintains all Sentry processing (including custom event processors) but prevents Sentry from sending any events to the backend. Note that, oddly, this still results in a request sent to sentry that notes how many events were discarded (not sent):
{"discarded_events":[{"reason":"before_send","category":"error","quantity":2}]}
This seems to not matter, so I'm going with this!