sentry-electron
sentry-electron copied to clipboard
Make `beforeSend` work from renderers
Renderer events are passed to the main process via the EventToMain integration. The downside of using an integration/global event processor to do this is that the renderer beforeSend never gets called.
This PR calls beforeSend from EventToMain so that it functions as it should!
This closes #533.
🤔 just realised this doesn't take into account any modifications to hint which is required to add attachments from beforeSend...
This now passes [event, hint] serialised from render to main and adds a test that ensures that hint.attachments added in the renderer beforeSend are submitted in envelopes from the main.
My understanding is this will currently only work with string attachments since UInt8Array get's mangled by json stringify.
beforeSend explicitly is meant to run after the event processors - https://develop.sentry.dev/sdk/unified-api/#event-pipeline, not sure if we can make this change.
beforeSendexplicitly is meant to run after the event processors
If EventToMain is the last integration, will this not be true?
not sure if we can make this change.
Currently, beforeSend is not called at all in the renderer process so it's currently not possible to do anything before an event is passed to the main process.
Alternatives
- Pass an optional
beforeSendcallback to theEventToMainintegration- I don't really like this because it needs documenting and differs from the SDK norms
- Stop using
EventToMainintegration and instead use a custom transport to pass to the main process- This has a few downsides including:
- We would need to parse the envelope from the renderer in the main process!
- It would almost certainly be a semver breaking change unless we somehow kept both routes working until v5
- This has a few downsides including:
#610 means this will no longer be required