Skip to content

Commit 8574543

Browse files
committed
add warnings
1 parent ddd79bf commit 8574543

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

packages/nextjs/src/client/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Client, EventProcessor, Integration } from '@sentry/core';
55
import { addEventProcessor, applySdkMetadata, consoleSandbox, getGlobalScope, GLOBAL_OBJ } from '@sentry/core';
66
import type { BrowserOptions } from '@sentry/react';
77
import { getDefaultIntegrations as getReactDefaultIntegrations, init as reactInit } from '@sentry/react';
8+
import { DEBUG_BUILD } from '../common/debug-build';
89
import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor';
910
import { getVercelEnv } from '../common/getVercelEnv';
1011
import { isRedirectNavigationError } from '../common/nextNavigationErrorUtils';
@@ -48,6 +49,15 @@ export function init(options: BrowserOptions): Client | undefined {
4849
}
4950
clientIsInitialized = true;
5051

52+
if (!DEBUG_BUILD && options.debug) {
53+
consoleSandbox(() => {
54+
// eslint-disable-next-line no-console
55+
console.warn(
56+
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `withSentryConfig({ disableLogger: true })` / `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
57+
);
58+
});
59+
}
60+
5161
// Remove cached trace meta tags for ISR/SSG pages before initializing
5262
// This prevents the browser tracing integration from using stale trace IDs
5363
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {

packages/nextjs/src/edge/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { getScopesFromContext } from '@sentry/opentelemetry';
2323
import type { VercelEdgeOptions } from '@sentry/vercel-edge';
2424
import { getDefaultIntegrations, init as vercelEdgeInit } from '@sentry/vercel-edge';
25+
import { DEBUG_BUILD } from '../common/debug-build';
2526
import { ATTR_NEXT_SPAN_TYPE } from '../common/nextSpanAttributes';
2627
import { TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION } from '../common/span-attributes-with-logic-attached';
2728
import { addHeadersAsAttributes } from '../common/utils/addHeadersAsAttributes';
@@ -55,6 +56,13 @@ export function init(options: VercelEdgeOptions = {}): void {
5556
return;
5657
}
5758

59+
if (!DEBUG_BUILD && options.debug) {
60+
// eslint-disable-next-line no-console
61+
console.warn(
62+
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `withSentryConfig({ disableLogger: true })` / `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
63+
);
64+
}
65+
5866
const customDefaultIntegrations = getDefaultIntegrations(options);
5967

6068
// This value is injected at build time, based on the output directory specified in the build config. Though a default

packages/nextjs/src/server/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ export function init(options: NodeOptions): NodeClient | undefined {
9696
return;
9797
}
9898

99+
if (!DEBUG_BUILD && options.debug) {
100+
// eslint-disable-next-line no-console
101+
console.warn(
102+
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `withSentryConfig({ disableLogger: true })` / `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
103+
);
104+
}
105+
99106
const customDefaultIntegrations = getDefaultIntegrations(options)
100107
.filter(integration => integration.name !== 'Http')
101108
.concat(

0 commit comments

Comments
 (0)