documentation for attaching metadata for native crashes
what's a correct way for attaching metadata for the native crashes when using @sentry/electron?
I use the following setup for adding additional information to the native crash event, so I know which app version crashed, not the version which uploaded the crash:
crashReporter.start({
uploadToServer: false,
});
(async () => {
const SentryEnv = import.meta.env.VITE_SENTRY_ENVIRONMENT;
if (['testing', 'beta', 'production'].includes(SentryEnv))
Sentry.init({
dsn: 'sentry',
sendDefaultPii: true,
integrations: [eventLoopBlockIntegration({ threshold: 3000, maxEventsPerHour: 3 })],
});
// manually add version number, because Sentry attaches the version number of the app that uploads the crash report, which could be different from the version in which the crash happened
crashReporter.addExtraParameter('appVersion', app.getVersion());
however I just tried using Sentry.setTag instead of crashReporter.addExtraParameter and it seems to work too, I'm pretty sure couple years ago when I was setting up crashReporter.addExtraParameter Sentry.setTag were getting lost, so are they now correctly attached and not overwritten by the uploading app session?
(async () => {
const SentryEnv = import.meta.env.VITE_SENTRY_ENVIRONMENT;
if (['testing', 'beta', 'production'].includes(SentryEnv))
Sentry.init({
dsn: 'sentry',
sendDefaultPii: true,
integrations: [eventLoopBlockIntegration({ threshold: 3000, maxEventsPerHour: 3 })],
});
// manually add version number, because Sentry attaches the version number of the app that uploads the crash report, which could be different from the version in which the crash happened
Sentry.setTag('session-app-version', app.getVersion());
If you don't pass a specific release to init the SDK will default to appName@appVersion.
We have a test that ensures the correct app version is included when a native crash occurs in the previous version: https://github.com/getsentry/sentry-electron/tree/master/test/e2e/test-apps/native-sentry/main-update
You should not be calling crashReporter.start manually. Native crash handling is already enabled by the SDK here:
https://github.com/getsentry/sentry-electron/blob/master/src/main/integrations/sentry-minidump/index.ts#L52