Search code examples
react-nativesentry

Sentry add context react native


I am trying to use sentry to track logs and errors on my react native application

I just did a simple test to understand how to add context

Sentry.init({
    dsn: 'https://***@***.ingest.sentry.io/***',
});
Sentry.setContext('foo', 'bar');
Sentry.captureException(new Error('test sentry error'));

My error is displayed in sentry but I can not see my extra context, I only have some undefined data in ADDITIONAL DATA

enter image description here


Solution

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

    In the docs here they have mistakenly put a string as an example.