nested breadcrumb data on android is not treated correctly
Environment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version? @sentry/react-native 3.2.3
Steps to Reproduce
Call Sentry.addBreadcrumb(...) in key places during app execution with nested data on Android before some reportError happens. normalizeDepth is not configured and so should be the default: 3?
Expected Result
- To see the nested breadcrumb data displayed like it is done for iOS events, as a tree.
- To be able to use advanced data scrubbing such as
[Mask] [Anything] from [$breadcrumb.data.**.access-token]to filter out sensitive values in the nested breadcrumb data, which is working for iOS events.
Actual Result
- The nested breadcrumb data objects are displayed like stringified JSON, the UI doesn't show them as a tree.
- Advanced data scrub rules do not match the nested keys and thus sensitive values remain.

The raw event indicates that the second level breadcrumb data objects are in fact serialized json strings:
{
"category" : "navigation",
"timestamp" : 1637957388.671,
"message" : "to: HealthQuestions-lINe0T4bK19QRqu6xATkl\nfrom: HealthQuestions-dwXLN-pRYJfyx-tk7OZb1",
"data" : {
"params" : "{\"analyticsParams\":{\"questionName\":\"WEIGHT\"},\"questionTag\":28}"
},
"type" : "navigation",
"level" : "info"
},
compared with iOS raw event data:
{
"data" : {
"params" : {
"questionTag" : 28,
"analyticsParams" : {
"questionName" : "WEIGHT"
}
}
},
"category" : "navigation",
"level" : "info",
"message" : "to: HealthQuestions-OAPrwTv68Z-GMpjTVcWe2\nfrom: HealthQuestions-eUubRHrlS0tumJjSwKDS4",
"type" : "navigation",
"timestamp" : 1638307295.225
},
We have also found an odd example (our sentry issue is 2825368904 and event is 3cd99275e3d645ea962d186440f3e648) where the breadcrumbs have been duplicated and half of them are displayed correctly and half are not, which may be a clue (and probably related to https://github.com/getsentry/sentry-react-native/issues/1409):
{
"category" : "api",
"timestamp" : 1637957164.673,
"message" : "(5) POST auth/sign_in/bankid - request",
"data" : {
"body" : {
"order_reference" : "60191dcc-<snip>",
"country_code" : "SE"
}
},
"type" : "default",
"level" : "info"
},
{
"level" : "info",
"type" : "default",
"data" : {
"body" : "{\"order_reference\":\"60191dcc-<snip>\",\"country_code\":\"SE\"}"
},
"message" : "(5) POST auth/sign_in/bankid - request",
"timestamp" : 1637957164.682,
"category" : "api"
},
Happy to work with you on this as this prohibits us from using breadcrumb in the useful way we had hoped.
@adbl thanks for reporting, will have a look at it. @jennmueng could you please check the https://github.com/getsentry/sentry-react-native/issues/1409#issuecomment-938599118 issue? thanks
Adding to this it seems that Android OS version might matter, testing today with android 10, and the breadcrumbs get displayed correctly. The strange issue with duplicates are Android OS 11.
I also suspect that this is somehow affected by android app life cycle -> javascript runtime/module loading. Perhaps it leads to us calling Sentry.init from JS multiple times in the same app instance...
we could run a test using the Sentry Android SDK v6 alpha that vendors Gson and this issue should be fixed by itself. If not, we can look into fixing it on Sentry Android SDK v5, since Gson parses it wrongly (stringify the data bag).
So the problem is that the RN SDK serializes the data field when syncing the scope own to the Native layer.
https://github.com/getsentry/sentry-react-native/blob/642d9332359ed8bfdced1920216c761888c71496/android/src/main/java/io/sentry/react/RNSentryModule.java#L421 https://github.com/getsentry/sentry-react-native/blob/642d9332359ed8bfdced1920216c761888c71496/src/js/wrapper.ts#L356-L358
https://github.com/getsentry/sentry-react-native/blob/642d9332359ed8bfdced1920216c761888c71496/src/js/wrapper.ts#L451-L468