Skip to content

Commit 6bb9dd1

Browse files
committed
only enable the logger in debug bundles
1 parent edf4a57 commit 6bb9dd1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/core/src/sdk.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getCurrentHub } from '@sentry/hub';
22
import { Client, Options } from '@sentry/types';
3-
import { logger } from '@sentry/utils';
3+
import { isDebugBuild, logger } from '@sentry/utils';
44

55
/** A class object that can instantiate Client objects. */
66
export type ClientClass<F extends Client, O extends Options> = new (options: O) => F;
@@ -14,7 +14,13 @@ export type ClientClass<F extends Client, O extends Options> = new (options: O)
1414
*/
1515
export function initAndBind<F extends Client, O extends Options>(clientClass: ClientClass<F, O>, options: O): void {
1616
if (options.debug === true) {
17-
logger.enable();
17+
if (isDebugBuild()) {
18+
logger.enable();
19+
} else {
20+
// use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped
21+
// eslint-disable-next-line no-console
22+
console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');
23+
}
1824
}
1925
const hub = getCurrentHub();
2026
const scope = hub.getScope();

0 commit comments

Comments
 (0)