diff --git a/CHANGELOG.md b/CHANGELOG.md index ea20caf583..7d35622114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Dynamically resolve `collectModulesScript` path to support monorepos ([#3092])(https://github.com/getsentry/sentry-react-native/pull/3092) +- Native wrapper methods don't throw disabled error after re-initializing [#3093](https://github.com/getsentry/sentry-react-native/pull/3093) ### Dependencies diff --git a/src/js/wrapper.ts b/src/js/wrapper.ts index 4b494bf6d0..0816002421 100644 --- a/src/js/wrapper.ts +++ b/src/js/wrapper.ts @@ -180,6 +180,7 @@ export const NATIVE: SentryNativeWrapper = { 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false', ); } + this.enableNative = true; return false; } @@ -187,6 +188,7 @@ export const NATIVE: SentryNativeWrapper = { logger.warn( 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.', ); + this.enableNative = false; return false; } @@ -201,6 +203,7 @@ export const NATIVE: SentryNativeWrapper = { const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions); this.nativeIsReady = nativeIsReady; + this.enableNative = true; return nativeIsReady; }, diff --git a/test/client.test.ts b/test/client.test.ts index dc2bfaee56..9e0b11bf7b 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -216,6 +216,7 @@ describe('Tests ReactNativeClient', () => { const client = new ReactNativeClient({ ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, enableNative: true, transport: () => new NativeTransport(), }); diff --git a/test/wrapper.test.ts b/test/wrapper.test.ts index d71b9e6fbe..a4b3f2e0f5 100644 --- a/test/wrapper.test.ts +++ b/test/wrapper.test.ts @@ -131,6 +131,7 @@ describe('Tests Native Wrapper', () => { }); test('does not initialize with autoInitializeNativeSdk: false', async () => { + NATIVE.enableNative = false; logger.warn = jest.fn(); await NATIVE.initNativeSdk({ @@ -487,6 +488,7 @@ describe('Tests Native Wrapper', () => { }); describe('closeNativeSdk', () => { + NATIVE.enableNative = true; test('closeNativeSdk calls native bridge', async () => { await NATIVE.closeNativeSdk();