Skip to content

Commit a577c4f

Browse files
committed
feat(core): Add sentry origin attribute to console logs integration
1 parent 9e477cd commit a577c4f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/core/src/logs/console-integration.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getClient } from '../currentScopes';
22
import { DEBUG_BUILD } from '../debug-build';
33
import { defineIntegration } from '../integration';
4+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
45
import type { ConsoleLevel, IntegrationFn } from '../types-hoist';
56
import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist';
67
import { _INTERNAL_captureLog } from './exports';
@@ -17,6 +18,10 @@ type GlobalObjectWithUtil = typeof GLOBAL_OBJ & {
1718

1819
const INTEGRATION_NAME = 'ConsoleLogs';
1920

21+
const DEFAULT_ATTRIBUTES = {
22+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.console.logging',
23+
};
24+
2025
const _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

Comments
 (0)