Sentry-react-native: additional json in captureException

Created on 26 Feb 2018  路  3Comments  路  Source: getsentry/sentry-react-native

OS:

  • [x] MacOS

_Platform:_

  • [x] iOS
v8.9.3
5.5.1

Config:

Sentry.config('https://[email protected]/...', {
 logLevel: SentryLog.Debug, // default SentryLog.None | Possible values:  .None, .Error, .Debug, .Verbose
        disableNativeIntegration: false, // default: false | Deactivates the native integration and only uses raven-js
        handlePromiseRejection: true, // default: true | Handle unhandled promise rejections
        ignoreModulesExclude: [], // default: [] | Exclude is always stronger than include
        ignoreModulesInclude: [], // default: [] | Include modules that should be ignored too
}).install()

While sending extra json with:

import {
    Sentry,
    SentrySeverity,
    SentryLog
} from 'react-native-sentry';

Sentry.config(/*...*/, {...}).install();
Sentry.captureException(new Error("welcome to sentry"), {user: 'u123'});

Actual result:
In the dashboard, the extra data ({user: 'u123'}) cannot be found

Expected result:
{user: 'u123'} in the dashboard for this error

Most helpful comment

I think I figured it out. Every time I want to send an exception, I do the following:

    Sentry.setExtraContext({ customData });
    Sentry.captureException(error);
    Sentry.setExtraContext({ customData: undefined });

customData will be added to that exception. You need to reset it afterwards otherwise customData will be added to all the other successive captured exceptions.

All 3 comments

Hey, sorry for the late reply.
This will not work for all possible event keys and in general, we recommend using setUserContext for this kind of behavior.
We are working on an update though which should make all this way more transparent.

I don't think this should be closed. The type of captureException implies that it is possible to send extra data. I guess this could be related to this issue https://github.com/getsentry/sentry-javascript/issues/1607
My point is, if truly that method ignore the second parameter, you should update its type definition, and write an example to achieve the same functionality.

I think I figured it out. Every time I want to send an exception, I do the following:

    Sentry.setExtraContext({ customData });
    Sentry.captureException(error);
    Sentry.setExtraContext({ customData: undefined });

customData will be added to that exception. You need to reset it afterwards otherwise customData will be added to all the other successive captured exceptions.

Was this page helpful?
0 / 5 - 0 ratings