Sentry-react-native: Context values not getting attached to native crashes

Created on 12 Oct 2019  路  11Comments  路  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [X ] MacOS
  • [ ] Linux

_Platform:_

  • [X ] iOS
  • [ ] Android

SDK:

  • [X ] @sentry/react-native 1.0.6
  • [ ] react-native-sentry

react-native version: 0.61.2

Init Code:

Sentry.init({
  dsn: 'https://[email protected]/xxxxx',
  environment: 'prod',
  attachStacktrace: true,
  debug: true,
});
Sentry.setRelease('friday');

Sentry.configureScope(scope => {
  scope.setTags({dogs: 'yes', cats: 'maybe'});
  scope.setExtras({things: 'stuff'});
  scope.setUser({id: 26, email: '[email protected]'});
});

I have following issue:

None of the values set on the scope come through on native crashes.

Steps to reproduce:
Add context to scope and trigger a native crash.

Actual result:
None of the scope data is displayed:

image

[no image of extra data to show here because it doesn't come through]

Expected result:
Scope data is added to event, as it is for JS events:

image

image

EDIT: Per @HazAT, this applies to breadcrumbs as well.

Most helpful comment

Same thing for us. We set the user id on the javascript side like this:

Sentry.setUser({ id: AppSettings.deviceLogin })

But there is a difference between native errors / js errors:
Sentry.nativeCrash() = Missing expected user id 馃憥
Sentry.captureException(new Error("JS Error")) = User id is present and correct 馃憤

Both these methods are called after Sentry.init & Sentry.setUser.

I would expect these values / tags to be configured on the native crash handlers as well.

All 11 comments

To add to this, scope.setContext or Sentry.setContext also currently doesn't work.

I'm experiencing the same issue.

This is also a huge problem for us. We can't track any tag data on native crashes.

The data coming from beforeSend method is also not sent along with the native crash log.

Same thing for us. We set the user id on the javascript side like this:

Sentry.setUser({ id: AppSettings.deviceLogin })

But there is a difference between native errors / js errors:
Sentry.nativeCrash() = Missing expected user id 馃憥
Sentry.captureException(new Error("JS Error")) = User id is present and correct 馃憤

Both these methods are called after Sentry.init & Sentry.setUser.

I would expect these values / tags to be configured on the native crash handlers as well.

Do you experience a missing context problem on iOS only? As far as I see the same issue occurs on Android as well.

Any update on this? This makes deciphering native crashes really difficult.

Any update on this? This makes deciphering native crashes really difficult.

Also wondering; we've held back on updating to @sentry/react-native because of this, but that means we're pretty out of date.

The context should be unified, the context should also be send to native sdk clearly. +1.

Same issue here. Would be really helpful to get it fixed. Exceptions on JS side get recorded fine with breadcrumbs and user data, crashes on the native side are missing breadcrumbs as well as user data (for us iOS as well as Android).

I am testing the following code after sentry init

Sentry.setContext('foo','bar');
Sentry.captureException(new Error('Test sentry error'));

My context is not displayed

In ADDITIONAL DATA I just have undefined values

Screenshot 2020-06-06 at 16 27 37

I am testing the following code after sentry init

Sentry.setContext('foo','bar');
Sentry.captureException(new Error('Test sentry error'));

My context is not displayed

In ADDITIONAL DATA I just have undefined values

Screenshot 2020-06-06 at 16 27 37

@ajouve Sentry.setContext takes an object as a second parameter and not a string:
http://getsentry.github.io/sentry-javascript/classes/hub.scope.html#setcontext

I see that in the docs here we have mistakenly put a string as an example. Is there anywhere else that you got the info from so we can go fix the documentation? Thanks!

Was this page helpful?
0 / 5 - 0 ratings