Skip to content

documentation for attaching metadata for native crashes #1255

@nikitakot

Description

@nikitakot

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());

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions