Allow native SDK options to be specified by user without needing to re-initialize native SDK. - TypeScript sentry-react-native
OS: - [ ] Windows - [x] MacOS - [ ] Linux
Platform: - [x] iOS - [ ] Android
SDK:
- [x] @sentry/react-native
(>= 1.0.0)
- [ ] react-native-sentry
(<= 0.43.2)
SDK version: 2.1.0
react-native
version: 0.63.4
Are you using Expo? - [ ] Yes - [x] No
Are you using sentry.io or on-premise? - [x] sentry.io (SaaS) - [ ] on-premise
If you are using sentry.io, please post a link to your issue so we can take a look:
Configuration:
(@sentry/react-native
)
Sentry.init({
dsn: 'https://...@sentry.io/...',
debug: false,
enableAutoSessionTracking: true,
integrations(integrations) {
return integrations.filter(integration => integration.name !== 'Breadcrumbs')
},
});
I have following issue:
I can see default breadcrumbs for native errors even after disabling Breadcrumbs
integration during initing SDK
Steps to reproduce: - Init SDK with disabling Breadcrumbs - Raise Native error - Check tracked breadcrumbs
Actual result:
You can see default native breadcrumbs
Expected result:
You should see only exception in breadcrumbs
6 Answer:
The issue is presented only on Native errors, on JS errors everything works as expected
Should I do this manually in Native code?
import Sentry
SentrySDK.start(options: [
//...
"integrations": Sentry.Options.defaultIntegrations().filter { (name) -> Bool in
return name != "SentryAutoBreadcrumbTrackingIntegration" // This will disable SentryAutoBreadcrumbTrackingIntegration
}
//...
])
https://docs.sentry.io/platforms/apple/usage/#integrations
Should I do this manually in Native code?
import Sentry SentrySDK.start(options: [ //... "integrations": Sentry.Options.defaultIntegrations().filter { (name) -> Bool in return name != "SentryAutoBreadcrumbTrackingIntegration" // This will disable SentryAutoBreadcrumbTrackingIntegration } //... ])
No you shouldn't do this as it will initialize the SDK twice and cause both to not be synced. Currently you're not able to disable just Native breadcrumbs, but there is a way to do it with patch-package
.
Follow the setup instructions for
patch-package
here: https://github.com/ds300/patch-packageAdd these lines below to
node_modules/@sentry/react-native/ios/RNSentry.m
insidestartWithOptions
.
reject(@"SentryReactNative", error.localizedDescription, error);
return;
}
+
+ NSMutableArray *integrations = [SentryOptions defaultIntegrations].mutableCopy;
+ [integrations removeObject:@"SentryAutoBreadcrumbTrackingIntegration"];
+ sentryOptions.integrations = integrations;
+
[SentrySDK startWithOptionsObject:sentryOptions];
resolve(@YES);
- Run
yarn patch-package @sentry/react-native
Now every time you run yarn install
it should patch the @sentry/react-native
package to disable this integration.
Actually, now that we just merged https://github.com/getsentry/sentry-react-native/pull/1259, when we release that you can just re-initialize the SDK in Swift/Objective-C and that won't break the SDK. However, for now you can use that patch-package workaround. Let's close this.
Now every time you run
yarn install
it should patch the@sentry/react-native
package to disable this integration.
Thanks! It works. It took me some time to test it in all environments.
Now all native breadcrumbs are disabled. Still, I have one issue with breadcrumbs.
JS-exceptions attach breadcrumbs from previous session (Android only)
Native exceptions don't as expected
@jennmueng can you help with it? It's a minor issue and I can create a separate bug report for it, if you want to.
JS-exceptions attach breadcrumbs from previous session
It seems like it only happens on Android
Read next
- [question] 502/499 errors when calling Centrifugo API - centrifugo
- Can you update the readme to include Windows users with private repo dependencies? - docker
- opencv File "tf_text_graph_ssd.py", assert(graph_def.node[0].op == 'Placeholder') AssertionError - Cplusplus
- design-system unable to successfully run full-start - JavaScript
- RecursiveComparisonDifferenceCalculator fails with IllegalStateException: Duplicate key - assertj-core
- implement better way to select GL profile - Java processing
- HaplotypeCaller: CRAMException: Attempt to unmapped with non zero alignment start (0) or span (150) - Java gatk
- Error: File name too long (os error 36): "" - kickstart