sentry-electron
sentry-electron copied to clipboard
Don't manage to send attachments
- [x] Review the documentation: https://docs.sentry.io/platforms/javascript/electron/
- [x] Search for existing issues: https://github.com/getsentry/sentry-electron/issues
- [x] Use the latest release: https://github.com/getsentry/sentry-electron/releases
- [x] Provide a link to the affected event from your Sentry account https://sentry.io/organizations/stephan-petzl/issues/3499972015/attachments/?project=1554144&query=is%3Aunresolved
Versions + Platform
- SDK version - @sentry/[email protected]
- Electron version - [email protected]
- Platform - Mac OS
Description
I am configuring Sentry like this:
function configure() {
var consoleError = console.error
console.error = function() {
var args = Array.prototype.slice.call(arguments)
const error = reduceConsoleArgs(args)
Sentry.configureScope(scope => {
console.log('configureScope1')
const runtimeData = getRuntimeData(store)
scope.addAttachment({ filename: 'context.json', data: JSON.stringify(runtimeData) })
})
Sentry.captureException(error, { level: 'error' })
return consoleError.apply(console, args)
}
}
Unfortunately no attachment is added to the report. Can somebody give me a hint?
The docs cover this. You should be using beforeSend:
https://docs.sentry.io/platforms/javascript/guides/electron/enriching-events/attachments/#add-or-modify-attachments-before-sending
Thanks @timfish, I read and tried that but it didn't work. Yesterday I figured out that I needed to set it up in the main thread instead of the renderer. However, the problem with this is that I don't have the attachment data in my main thread. Is there a way to pass it over? I know about IPC, but there is a timing issue: How would I know WHEN to send the attachment data to the main thread in order to have it available when beforeSend gets executed...?
With the Electron SDK, all events are sent from the main process. The issue with adding attachments in the renderer is that they will need to be sent over IPC to the main process and this currently uses JSON which will likely have terrible performance sending anything large or binary.
~~On newer versions of Electron (>=v17) we can use structuredClone() instead which will have better performance.~~
This wont work when using the fetch IPC.
I don't need to send a lot. Not a problem performance wise. But I still don't know how to get the data sent to the main thread in time so it can be used in "beforeSend"...?
@timfish I just checked your PR, but unfortunately I can't seem to figure out:
- how do I make use of it?
- which version of electron/sentry is going to be fixing this issue?
This hasn't made it into a release yet but once it has, you'll be able to add attachments in beforeSend in the renderers as per the browser docs:
https://docs.sentry.io/platforms/javascript/enriching-events/attachments/#add-or-modify-attachments-before-sending