@sentry/browser
@sentry/node
raven-js
raven-node
_(raven for node)_4.0.2
The previous version raven-js
had the ability to add setDataCallback
which was executed before data was sent out. Current version @sentry/browser
enables beforeSend
but it can be only set as part of the init
process.
Could you please add an ability to set beforeSend
callback also in a later stage? I am trying to fix my redux integration previously done using https://github.com/captbaritone/raven-for-redux/blob/master/index.js
Hey, you should be able to use an event processor.
So in any point in time you can do:
Sentry.configureScope(scope => {
scope.addEventProcessor(async event => {
// Add anything to the event here
// returning null will not send the event
return event;
});
});
Hope this helps.
Works beautifully! Thanks :)
You could also add this in the docs...
@pkuczynski
Updated the section
https://docs.sentry.io/platforms/javascript/#eventprocessors
Beautiful! Thanks :)
Hi.
I've tried using the scope.addEventProcessor
method to add extra data to the scope. It was going well until I noticed that this method gets called when sentry is about to send the error and not when the error is thrown. Since I'm using Redux, I'm getting misleading information as there are breadcrumbs which happened after the exception.
Any ideas on how to deal with this?
For reference, I got it working by storing the state when the lastEventId
is changed (which means an error was thrown) and then using this stored data to modify the scope using addEventProcessor
.
You can check out this gist: https://gist.github.com/olavoasantos/9ac791098758ee7dedf0c0424ec8b398
It looks like the section on event processors was removed from the documentation. Is this still the recommended way to look up and attach additional metadata when Sentry is about to send an exception? Or do we use beforeSend
now?
@cyounkins both are correct, but beforeSend
can be set just once during initialization, where eventProcessors
can be added anytime and they can also work for only specific events (scope) if desired. https://docs.sentry.io/platforms/node/#eventprocessors
(JS docs are being reworked now, thus some parts may be missing, sorry about that)
Most helpful comment
Hey, you should be able to use an event processor.
So in any point in time you can do:
Hope this helps.