Skip to content

Commit 682b73f

Browse files
antonisclaude
andcommitted
refactor(core): Move __DEV__ guard to call site in sdk.tsx
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 19611d8 commit 682b73f

3 files changed

Lines changed: 3 additions & 20 deletions

File tree

packages/core/src/js/sdk.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export function init(passedOptions: ReactNativeOptions): void {
173173
defaultIntegrations,
174174
});
175175
initAndBind(ReactNativeClient, options);
176-
checkSentryJsSdkVersionMismatch();
176+
if (__DEV__) {
177+
checkSentryJsSdkVersionMismatch();
178+
}
177179

178180
if (isExpoGo()) {
179181
debug.log('Offline caching, native errors features are not available in Expo Go.');

packages/core/src/js/utils/sdkVersionCheck.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { debug, getMainCarrier, SDK_VERSION as CORE_SDK_VERSION } from '@sentry/core';
22

33
export function checkSentryJsSdkVersionMismatch(): void {
4-
if (!__DEV__) {
5-
return;
6-
}
7-
84
try {
95
const carrier = getMainCarrier();
106
const sentryCarrier = carrier.__SENTRY__;

packages/core/test/utils/sdkVersionCheck.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,6 @@ describe('checkSentryJsSdkVersionMismatch', () => {
6262
expect(mockDebugWarn).not.toHaveBeenCalled();
6363
});
6464

65-
it('does not warn in production builds', () => {
66-
// @ts-expect-error -- __DEV__ is a RN global
67-
globalThis.__DEV__ = false;
68-
try {
69-
mockCarrier.__SENTRY__ = { '10.0.0': {}, '9.0.0': {} };
70-
71-
checkSentryJsSdkVersionMismatch();
72-
73-
expect(mockDebugWarn).not.toHaveBeenCalled();
74-
} finally {
75-
// @ts-expect-error -- __DEV__ is a RN global
76-
globalThis.__DEV__ = true;
77-
}
78-
});
79-
8065
it('does not throw on unexpected errors', () => {
8166
Object.defineProperty(mockCarrier, '__SENTRY__', {
8267
get() {

0 commit comments

Comments
 (0)