File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import {
2+ addBreadcrumb ,
3+ addConsoleInstrumentationHandler ,
4+ defineIntegration ,
5+ getClient ,
6+ safeJoin ,
7+ severityLevelFromString ,
8+ } from '@sentry/core' ;
9+
10+ const INTEGRATION_NAME = 'Console' ;
11+
12+ /**
13+ * Capture console logs as breadcrumbs. Enabled by default in the Cloudflare SDK.
14+ */
15+ export const consoleIntegration = defineIntegration ( ( ) => {
16+ return {
17+ name : INTEGRATION_NAME ,
18+ setup ( client ) {
19+ addConsoleInstrumentationHandler ( ( { args, level } ) => {
20+ if ( getClient ( ) !== client ) {
21+ return ;
22+ }
23+
24+ addBreadcrumb (
25+ {
26+ category : 'console' ,
27+ level : severityLevelFromString ( level ) ,
28+ message : safeJoin ( args , ' ' ) ,
29+ } ,
30+ {
31+ input : [ ...args ] ,
32+ level,
33+ } ,
34+ ) ;
35+ } ) ;
36+ } ,
37+ } ;
38+ } ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { CloudflareClient } from './client';
1414import { fetchIntegration } from './integrations/fetch' ;
1515import { makeCloudflareTransport } from './transport' ;
1616import { defaultStackParser } from './vendor/stacktrace' ;
17+ import { consoleIntegration } from './integrations/console' ;
1718
1819/** Get the default integrations for the Cloudflare SDK. */
1920export function getDefaultIntegrations ( options : CloudflareOptions ) : Integration [ ] {
@@ -27,6 +28,7 @@ export function getDefaultIntegrations(options: CloudflareOptions): Integration[
2728 linkedErrorsIntegration ( ) ,
2829 fetchIntegration ( ) ,
2930 requestDataIntegration ( sendDefaultPii ? undefined : { include : { cookies : false } } ) ,
31+ consoleIntegration ( ) ,
3032 ] ;
3133}
3234
You can’t perform that action at this time.
0 commit comments