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 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; }