Skip to content

Commit 3c63bec

Browse files
authored
ref(browser): Use debug instead of logger (#17029)
resolves #16952 resolves #16951
1 parent 78b8e4b commit 3c63bec

File tree

17 files changed

+62
-64
lines changed

17 files changed

+62
-64
lines changed

packages/browser-utils/src/getNativeImplementation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isNativeFunction, logger } from '@sentry/core';
1+
import { debug, isNativeFunction } from '@sentry/core';
22
import { DEBUG_BUILD } from './debug-build';
33
import { WINDOW } from './types';
44

@@ -53,7 +53,7 @@ export function getNativeImplementation<T extends keyof CacheableImplementations
5353
document.head.removeChild(sandbox);
5454
} catch (e) {
5555
// Could not create sandbox iframe, just use window.xxx
56-
DEBUG_BUILD && logger.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);
56+
DEBUG_BUILD && debug.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);
5757
}
5858
}
5959

packages/browser-utils/src/metrics/cls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Client, SpanAttributes } from '@sentry/core';
22
import {
33
browserPerformanceTimeOrigin,
4+
debug,
45
getCurrentScope,
56
htmlTreeAsString,
6-
logger,
77
SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,
88
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT,
99
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE,
@@ -53,7 +53,7 @@ function sendStandaloneClsSpan(
5353
pageloadSpanId: string,
5454
reportEvent: WebVitalReportEvent,
5555
) {
56-
DEBUG_BUILD && logger.log(`Sending CLS span (${clsValue})`);
56+
DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);
5757

5858
const startTime = msToSec((browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));
5959
const routeName = getCurrentScope().getScopeData().transactionName;

packages/browser-utils/src/metrics/instrument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFunctionName, logger } from '@sentry/core';
1+
import { debug, getFunctionName } from '@sentry/core';
22
import { DEBUG_BUILD } from '../debug-build';
33
import { onCLS } from './web-vitals/getCLS';
44
import { onFID } from './web-vitals/getFID';
@@ -214,7 +214,7 @@ function triggerHandlers(type: InstrumentHandlerType, data: unknown): void {
214214
handler(data);
215215
} catch (e) {
216216
DEBUG_BUILD &&
217-
logger.error(
217+
debug.error(
218218
`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError:`,
219219
e,
220220
);

packages/browser-utils/src/metrics/lcp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Client, SpanAttributes } from '@sentry/core';
22
import {
33
browserPerformanceTimeOrigin,
4+
debug,
45
getCurrentScope,
56
htmlTreeAsString,
6-
logger,
77
SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,
88
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT,
99
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE,
@@ -56,7 +56,7 @@ export function _sendStandaloneLcpSpan(
5656
pageloadSpanId: string,
5757
reportEvent: WebVitalReportEvent,
5858
) {
59-
DEBUG_BUILD && logger.log(`Sending LCP span (${lcpValue})`);
59+
DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);
6060

6161
const startTime = msToSec((browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));
6262
const routeName = getCurrentScope().getScopeData().transactionName;

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import {
1919
addBreadcrumb,
2020
addConsoleInstrumentationHandler,
2121
addFetchInstrumentationHandler,
22+
debug,
2223
defineIntegration,
2324
getBreadcrumbLogLevelFromHttpStatusCode,
2425
getClient,
2526
getComponentName,
2627
getEventDescription,
2728
htmlTreeAsString,
28-
logger,
2929
parseUrl,
3030
safeJoin,
3131
severityLevelFromString,
@@ -142,7 +142,7 @@ function _getDomBreadcrumbHandler(
142142
typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;
143143
if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {
144144
DEBUG_BUILD &&
145-
logger.warn(
145+
debug.warn(
146146
`\`dom.maxStringLength\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,
147147
);
148148
maxStringLength = MAX_ALLOWED_STRING_LENGTH;

packages/browser/src/integrations/browsersession.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { captureSession, defineIntegration, logger, startSession } from '@sentry/core';
1+
import { captureSession, debug, defineIntegration, startSession } from '@sentry/core';
22
import { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';
33
import { DEBUG_BUILD } from '../debug-build';
44
import { WINDOW } from '../helpers';
@@ -15,7 +15,7 @@ export const browserSessionIntegration = defineIntegration(() => {
1515
setupOnce() {
1616
if (typeof WINDOW.document === 'undefined') {
1717
DEBUG_BUILD &&
18-
logger.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');
18+
debug.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');
1919
return;
2020
}
2121

packages/browser/src/integrations/featureFlags/unleash/integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
_INTERNAL_addFeatureFlagToActiveSpan,
44
_INTERNAL_copyFlagsFromScopeToEvent,
55
_INTERNAL_insertFlagToScope,
6+
debug,
67
defineIntegration,
78
fill,
8-
logger,
99
} from '@sentry/core';
1010
import { DEBUG_BUILD } from '../../../debug-build';
1111
import type { UnleashClient, UnleashClientClass } from './types';
@@ -73,7 +73,7 @@ function _wrappedIsEnabled(
7373
_INTERNAL_insertFlagToScope(toggleName, result);
7474
_INTERNAL_addFeatureFlagToActiveSpan(toggleName, result);
7575
} else if (DEBUG_BUILD) {
76-
logger.error(
76+
debug.error(
7777
`[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${toggleName} (${typeof toggleName}), result: ${result} (${typeof result})`,
7878
);
7979
}

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import {
33
addGlobalErrorInstrumentationHandler,
44
addGlobalUnhandledRejectionInstrumentationHandler,
55
captureEvent,
6+
debug,
67
defineIntegration,
78
getClient,
89
getLocationHref,
910
isPrimitive,
1011
isString,
11-
logger,
1212
UNKNOWN_FUNCTION,
1313
} from '@sentry/core';
1414
import type { BrowserClient } from '../client';
@@ -188,7 +188,7 @@ function _enhanceEventWithInitialFrame(
188188
}
189189

190190
function globalHandlerLog(type: string): void {
191-
DEBUG_BUILD && logger.log(`Global Handler attached: ${type}`);
191+
DEBUG_BUILD && debug.log(`Global Handler attached: ${type}`);
192192
}
193193

194194
function getOptions(): { stackParser: StackParser; attachStacktrace?: boolean } {

packages/browser/src/integrations/httpclient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
addExceptionMechanism,
44
addFetchInstrumentationHandler,
55
captureEvent,
6+
debug,
67
defineIntegration,
78
getClient,
89
GLOBAL_OBJ,
910
isSentryRequestUrl,
10-
logger,
1111
supportsNativeFetch,
1212
} from '@sentry/core';
1313
import { addXhrInstrumentationHandler, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';
@@ -333,7 +333,7 @@ function _wrapXHR(client: Client, options: HttpClientOptions): void {
333333
try {
334334
_xhrResponseHandler(options, xhr, method, headers, error || virtualError);
335335
} catch (e) {
336-
DEBUG_BUILD && logger.warn('Error while extracting response event form XHR response', e);
336+
DEBUG_BUILD && debug.warn('Error while extracting response event form XHR response', e);
337337
}
338338
});
339339
}

packages/browser/src/integrations/spotlight.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Client, Envelope, Event, IntegrationFn } from '@sentry/core';
2-
import { defineIntegration, logger, serializeEnvelope } from '@sentry/core';
2+
import { debug, defineIntegration, serializeEnvelope } from '@sentry/core';
33
import { getNativeImplementation } from '@sentry-internal/browser-utils';
44
import { DEBUG_BUILD } from '../debug-build';
55
import type { WINDOW } from '../helpers';
@@ -20,7 +20,7 @@ const _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {
2020
return {
2121
name: INTEGRATION_NAME,
2222
setup: () => {
23-
DEBUG_BUILD && logger.log('Using Sidecar URL', sidecarUrl);
23+
DEBUG_BUILD && debug.log('Using Sidecar URL', sidecarUrl);
2424
},
2525
// We don't want to send interaction transactions/root spans created from
2626
// clicks within Spotlight to Sentry. Neither do we want them to be sent to
@@ -38,7 +38,7 @@ function setupSidecarForwarding(client: Client, sidecarUrl: string): void {
3838

3939
client.on('beforeEnvelope', (envelope: Envelope) => {
4040
if (failCount > 3) {
41-
logger.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);
41+
debug.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);
4242
return;
4343
}
4444

@@ -58,7 +58,7 @@ function setupSidecarForwarding(client: Client, sidecarUrl: string): void {
5858
},
5959
err => {
6060
failCount++;
61-
logger.error(
61+
debug.error(
6262
"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/",
6363
err,
6464
);

0 commit comments

Comments
 (0)