Skip to content

Commit 14474fe

Browse files
chargomeclaude
andauthored
feat(browser)!: Record console breadcrumbs via consoleIntegration (#24387)
Removes the `console` option from `breadcrumbsIntegration` and enables the core `consoleIntegration` by default instead, matching the server-side SDKs. It only records breadcrumbs, no logs. Refs #17702 --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent d7ae1bd commit 14474fe

16 files changed

Lines changed: 17 additions & 48 deletions

File tree

‎MIGRATION.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ Sentry.init({
15291529
15301530
### `@sentry/browser`
15311531
1532+
- The `console` option was removed from `breadcrumbsIntegration`. Console breadcrumbs now come from the default `consoleIntegration`: filter out the `Console` integration to disable them, or add `consoleIntegration()` if you set `defaultIntegrations: false`.
15321533
- The experimental `_experiments.enableStandaloneClsSpans` and `_experiments.enableStandaloneLcpSpans` options were removed from both `browserTracingIntegration` and `webVitalsIntegration`. CLS and LCP are no longer configurable: they are recorded as measurements on the pageload span, unless span streaming is enabled (`traceLifecycle: 'stream'`), in which case they are sent as dedicated spans.
15331534
- INP is now always sent as a web vital span (streamed when span streaming is enabled, standalone otherwise) that carries its value as a `browser.web_vital.inp.value` attribute. Previously, with span streaming disabled, INP was sent as a standalone span that carried its value as a span measurement.
15341535

‎dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/console/init.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Sentry.init({
66
traceLifecycle: 'static',
77
dsn: 'https://public@dsn.ingest.sentry.io/1337',
88
defaultIntegrations: false,
9-
integrations: [Sentry.breadcrumbsIntegration()],
9+
integrations: [Sentry.breadcrumbsIntegration(), Sentry.consoleIntegration()],
1010
sampleRate: 1,
1111
});

‎dev-packages/browser-integration-tests/suites/public-api/debug/test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sentryTest('logs debug messages correctly', async ({ getLocalTestUrl, page }) =>
3636
'Sentry Logger [log]: Integration installed: ConversationId',
3737
'Sentry Logger [log]: Integration installed: BrowserApiErrors',
3838
'Sentry Logger [log]: Integration installed: Breadcrumbs',
39+
'Sentry Logger [log]: Integration installed: Console',
3940
'Sentry Logger [log]: Global Handler attached: onerror',
4041
'Sentry Logger [log]: Global Handler attached: onunhandledrejection',
4142
'Sentry Logger [log]: Integration installed: GlobalHandlers',

‎packages/angular/src/sdk.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import type { Client, Integration } from '@sentry/core';
1414
import {
1515
applySdkMetadata,
16+
consoleIntegration,
1617
conversationIdIntegration,
1718
debug,
1819
dedupeIntegration,
@@ -38,6 +39,7 @@ export function getDefaultIntegrations(_options: BrowserOptions = {}): Integrati
3839
functionToStringIntegration(),
3940
conversationIdIntegration(),
4041
breadcrumbsIntegration(),
42+
consoleIntegration(),
4143
globalHandlersIntegration(),
4244
linkedErrorsIntegration(),
4345
dedupeIntegration(),

‎packages/astro/src/index.types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from '@sentry/node';
1919
export declare function init(options: Options | clientSdk.BrowserOptions | NodeOptions): Client | undefined;
2020

2121
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
22+
export declare const consoleIntegration: typeof serverSdk.consoleIntegration;
2223
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
2324
export declare const startSpan: typeof clientSdk.startSpan;
2425
export declare const startSpanManual: typeof clientSdk.startSpanManual;

‎packages/browser/src/exports.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export {
6262
functionToStringIntegration,
6363
eventFiltersIntegration,
6464
dedupeIntegration,
65+
consoleIntegration,
6566
parameterize,
6667
startSession,
6768
captureSession,

‎packages/browser/src/integrations/breadcrumbs.ts‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ import type {
66
Event as SentryEvent,
77
FetchBreadcrumbData,
88
FetchBreadcrumbHint,
9-
HandlerDataConsole,
109
HandlerDataFetch,
1110
IntegrationFn,
1211
} from '@sentry/core';
1312
import {
1413
addBreadcrumb,
15-
addConsoleInstrumentationHandler,
1614
addFetchInstrumentationHandler,
1715
debug,
1816
defineIntegration,
1917
getBreadcrumbLogLevelFromHttpStatusCode,
2018
getClient,
2119
getEventDescription,
2220
parseUrl,
23-
safeJoin,
24-
severityLevelFromString,
2521
} from '@sentry/core';
2622
import type { FetchHint, HandlerDataDom, HandlerDataHistory, HandlerDataXhr } from '@sentry/browser-utils';
2723
import {
@@ -37,7 +33,6 @@ import { DEBUG_BUILD } from '../debug-build';
3733
import { WINDOW } from '../helpers';
3834

3935
interface BreadcrumbsOptions {
40-
console: boolean;
4136
dom:
4237
| boolean
4338
| {
@@ -57,7 +52,6 @@ const INTEGRATION_NAME = 'Breadcrumbs' as const;
5752

5853
const _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {
5954
const _options = {
60-
console: true,
6155
dom: true,
6256
fetch: true,
6357
history: true,
@@ -69,10 +63,6 @@ const _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) =>
6963
return {
7064
name: INTEGRATION_NAME,
7165
setup(client) {
72-
// TODO(v11): Remove this functionality and use `consoleIntegration` from @sentry/core instead.
73-
if (_options.console) {
74-
addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));
75-
}
7666
if (_options.dom) {
7767
addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));
7868
}
@@ -180,42 +170,6 @@ function _getDomBreadcrumbHandler(
180170
};
181171
}
182172

183-
/**
184-
* Creates breadcrumbs from console API calls
185-
*/
186-
function _getConsoleBreadcrumbHandler(client: Client): (handlerData: HandlerDataConsole) => void {
187-
return function _consoleBreadcrumb(handlerData: HandlerDataConsole): void {
188-
if (getClient() !== client) {
189-
return;
190-
}
191-
192-
const breadcrumb = {
193-
category: 'console',
194-
data: {
195-
arguments: handlerData.args,
196-
logger: 'console',
197-
},
198-
level: severityLevelFromString(handlerData.level),
199-
message: safeJoin(handlerData.args, ' '),
200-
};
201-
202-
if (handlerData.level === 'assert') {
203-
if (handlerData.args[0] === false) {
204-
breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;
205-
breadcrumb.data.arguments = handlerData.args.slice(1);
206-
} else {
207-
// Don't capture a breadcrumb for passed assertions
208-
return;
209-
}
210-
}
211-
212-
addBreadcrumb(breadcrumb, {
213-
input: handlerData.args,
214-
level: handlerData.level,
215-
});
216-
};
217-
}
218-
219173
/**
220174
* Creates breadcrumbs from XHR API calls
221175
*/

‎packages/browser/src/sdk.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Client, Integration, Options } from '@sentry/core';
22
import {
3+
consoleIntegration,
34
conversationIdIntegration,
45
dedupeIntegration,
56
eventFiltersIntegration,
@@ -36,6 +37,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
3637
conversationIdIntegration(),
3738
browserApiErrorsIntegration(),
3839
breadcrumbsIntegration(),
40+
consoleIntegration(),
3941
globalHandlersIntegration(),
4042
linkedErrorsIntegration(),
4143
dedupeIntegration(),

‎packages/effect/src/index.types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export declare function effectLayer(
2020

2121
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined;
2222
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
23+
export declare const consoleIntegration: typeof serverSdk.consoleIntegration;
2324
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
2425
export declare const SentryEffectTracer: typeof clientSdk.SentryEffectTracer;
2526
export declare const startSpan: typeof clientSdk.startSpan;

‎packages/nextjs/test/clientSdk.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('Client init()', () => {
128128
type ModifiedInitOptionsIntegrationArray = { defaultIntegrations: Integration[]; integrations: Integration[] };
129129

130130
it('supports passing unrelated integrations through options', () => {
131-
init({ integrations: [breadcrumbsIntegration({ console: false })] });
131+
init({ integrations: [breadcrumbsIntegration({ dom: false })] });
132132

133133
const reactInitOptions = reactInit.mock.calls[0]![0] as ModifiedInitOptionsIntegrationArray;
134134
const installedBreadcrumbsIntegration = findIntegrationByName(reactInitOptions.integrations, 'Breadcrumbs');

0 commit comments

Comments
 (0)