From e3b8c33c748aef6ae0a74665b977b5858d7b1dc5 Mon Sep 17 00:00:00 2001 From: cruzach Date: Fri, 24 Jul 2020 12:00:39 -0400 Subject: [PATCH 1/2] fix: don't initiate native integration if enablenative is false --- src/js/sdk.ts | 30 ++++++++++++++++++------------ src/js/wrapper.ts | 8 ++++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/js/sdk.ts b/src/js/sdk.ts index 6a41875376..7a7e5e91d0 100644 --- a/src/js/sdk.ts +++ b/src/js/sdk.ts @@ -65,20 +65,15 @@ export function init( } } return frame; - } - }), - new DeviceContext() + }, + }) ); + if (options.enableNative) { + options.defaultIntegrations.push(new DeviceContext()); + } + options = assignDefaultOptions(options); } - if (options.enableNative === undefined) { - options.enableNative = true; - } - if (options.enableNativeCrashHandling === undefined) { - options.enableNativeCrashHandling = true; - } - if (options.enableNativeNagger === undefined) { - options.enableNativeNagger = true; - } + // tslint:enable: strict-comparisons initAndBind(ReactNativeClient, options); @@ -125,3 +120,14 @@ export function nativeCrash(): void { client.nativeCrash(); } } + +function assignDefaultOptions( + providedOptions: ReactNativeOptions +): ReactNativeOptions { + const defaultOptions: ReactNativeOptions = { + enableNative: true, + enableNativeCrashHandling: true, + enableNativeNagger: true, + }; + return { ...defaultOptions, ...providedOptions }; +} diff --git a/src/js/wrapper.ts b/src/js/wrapper.ts index 8a87d97227..ed94369d0c 100644 --- a/src/js/wrapper.ts +++ b/src/js/wrapper.ts @@ -56,7 +56,9 @@ export const NATIVE = { * Starts native with the provided options. * @param options ReactNativeOptions */ - async startWithOptions(options: ReactNativeOptions = {}): Promise { + async startWithOptions( + options: ReactNativeOptions = { enableNative: true } + ): Promise { if (!options.dsn) { logger.warn( "Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized." @@ -64,8 +66,10 @@ export const NATIVE = { return false; } if (!options.enableNative) { + if (!options.enableNativeNagger) { + logger.warn("Note: Native Sentry SDK is disabled."); + } this.enableNative = false; - logger.warn("Note: Native Sentry SDK is disabled."); return false; } From f82efb7f6e62449fe47148f74e26416f99c2d8ba Mon Sep 17 00:00:00 2001 From: cruzach Date: Fri, 24 Jul 2020 12:00:48 -0400 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 938f65ba8f..1395e6fe4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Unreleased - fix: Use `LogBox` instead of `YellowBox` if possible. #989 +- fix: Don't add `DeviceContext` default integration if `enableNative` is set to `false`. #993 +- fix: Don't log "Native Sentry SDK is disabled" if `enableNativeNagger` is set to `false`. #993 ## 1.6.3