11import { getClient } from '../currentScopes' ;
22import { DEBUG_BUILD } from '../debug-build' ;
33import { defineIntegration } from '../integration' ;
4+ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes' ;
45import type { ConsoleLevel , IntegrationFn } from '../types-hoist' ;
56import { CONSOLE_LEVELS , GLOBAL_OBJ , addConsoleInstrumentationHandler , logger , safeJoin } from '../utils-hoist' ;
67import { _INTERNAL_captureLog } from './exports' ;
@@ -17,6 +18,10 @@ type GlobalObjectWithUtil = typeof GLOBAL_OBJ & {
1718
1819const INTEGRATION_NAME = 'ConsoleLogs' ;
1920
21+ const DEFAULT_ATTRIBUTES = {
22+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.console.logging' ,
23+ } ;
24+
2025const _consoleLoggingIntegration = ( ( options : Partial < CaptureConsoleOptions > = { } ) => {
2126 const levels = options . levels || CONSOLE_LEVELS ;
2227
@@ -38,7 +43,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
3843 const followingArgs = args . slice ( 1 ) ;
3944 const message =
4045 followingArgs . length > 0 ? `Assertion failed: ${ formatConsoleArgs ( followingArgs ) } ` : 'Assertion failed' ;
41- _INTERNAL_captureLog ( { level : 'error' , message } ) ;
46+ _INTERNAL_captureLog ( { level : 'error' , message, attributes : DEFAULT_ATTRIBUTES } ) ;
4247 }
4348 return ;
4449 }
@@ -48,6 +53,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
4853 level : isLevelLog ? 'info' : level ,
4954 message : formatConsoleArgs ( args ) ,
5055 severityNumber : isLevelLog ? 10 : undefined ,
56+ attributes : DEFAULT_ATTRIBUTES ,
5157 } ) ;
5258 } ) ;
5359 } ,
0 commit comments