Sentry-react-native: Breadcrumbs should display JSON representation of objects instead of "[object Object]"

Created on 12 Sep 2017  路  7Comments  路  Source: getsentry/sentry-react-native

Sentry Breadcrumbs display object.toString() representation for console.log('message', {value: 1}), which is quite useless. The console arguments should be sent to Sentry in JSON (JSON.stringify()) so as the values are displayed instead of [object Object].

image

Most helpful comment

can we use beforeBreadcrumb on react-native-sentry?

All 7 comments

Hey,
I will look into this.

Would be great if it's similar to console improvement made in Chrome since 60 (or 61), which show collapsed snippets of elements inside the Object before expanding the object in console logs.

So, I guess we will not add this by default right now.
You could run JSON.stringify(object) yourself before adding a breadcrumb.

can we use beforeBreadcrumb on react-native-sentry?

Is there a best practice for capturing objects in logs? Aside from refactoring the console logs in my app to JSON.stringify the contents? Thanks

Something like this:

  beforeBreadcrumb: breadcrumb => {
    if (breadcrumb.category === 'console') {
      breadcrumb.message = JSON.stringify(breadcrumb.data.arguments)
    }
    return breadcrumb
  }
Was this page helpful?
0 / 5 - 0 ratings