Skip to content

Commit ea5993d

Browse files
committed
only attach the logger to __SENTRY__ in debug bundles
1 parent f1863b2 commit ea5993d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/utils/src/logger.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { WrappedFunction } from '@sentry/types';
33

4+
import { isDebugBuild } from './env';
45
import { getGlobalObject } from './global';
56

67
// TODO: Implement different loggers for different environments
@@ -104,8 +105,13 @@ class Logger {
104105
}
105106
}
106107

107-
// Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
108-
global.__SENTRY__ = global.__SENTRY__ || {};
109-
const logger = (global.__SENTRY__.logger as Logger) || (global.__SENTRY__.logger = new Logger());
108+
const sentryGlobal = global.__SENTRY__ || {};
109+
const logger = (sentryGlobal.logger as Logger) || new Logger();
110+
111+
if (isDebugBuild()) {
112+
// Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
113+
sentryGlobal.logger = logger;
114+
global.__SENTRY__ = sentryGlobal;
115+
}
110116

111117
export { logger };

0 commit comments

Comments
 (0)