diff --git a/dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts b/dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts index 00e918ce9719..183c80eb35be 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts @@ -23,7 +23,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'trace', body: { stringValue: 'console.trace 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 1, @@ -37,7 +44,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'debug', body: { stringValue: 'console.debug 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 5, @@ -51,7 +65,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'info', body: { stringValue: 'console.log 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 10, @@ -65,7 +86,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'info', body: { stringValue: 'console.info 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 9, @@ -79,7 +107,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'warn', body: { stringValue: 'console.warn 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 13, @@ -93,7 +128,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'error', body: { stringValue: 'console.error 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 17, @@ -107,7 +149,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page { severityText: 'error', body: { stringValue: 'Assertion failed: console.assert 123 false' }, - attributes: [], + attributes: [ + { + key: 'sentry.origin', + value: { + stringValue: 'auto.console.logging', + }, + }, + ], timeUnixNano: expect.any(String), traceId: expect.any(String), severityNumber: 17, diff --git a/packages/core/src/logs/console-integration.ts b/packages/core/src/logs/console-integration.ts index 6dbb829db5a6..d0fe2a639738 100644 --- a/packages/core/src/logs/console-integration.ts +++ b/packages/core/src/logs/console-integration.ts @@ -1,6 +1,7 @@ import { getClient } from '../currentScopes'; import { DEBUG_BUILD } from '../debug-build'; import { defineIntegration } from '../integration'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes'; import type { ConsoleLevel, IntegrationFn } from '../types-hoist'; import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist'; import { _INTERNAL_captureLog } from './exports'; @@ -17,6 +18,10 @@ type GlobalObjectWithUtil = typeof GLOBAL_OBJ & { const INTEGRATION_NAME = 'ConsoleLogs'; +const DEFAULT_ATTRIBUTES = { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.console.logging', +}; + const _consoleLoggingIntegration = ((options: Partial = {}) => { const levels = options.levels || CONSOLE_LEVELS; @@ -38,7 +43,7 @@ const _consoleLoggingIntegration = ((options: Partial = { const followingArgs = args.slice(1); const message = followingArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(followingArgs)}` : 'Assertion failed'; - _INTERNAL_captureLog({ level: 'error', message }); + _INTERNAL_captureLog({ level: 'error', message, attributes: DEFAULT_ATTRIBUTES }); } return; } @@ -48,6 +53,7 @@ const _consoleLoggingIntegration = ((options: Partial = { level: isLevelLog ? 'info' : level, message: formatConsoleArgs(args), severityNumber: isLevelLog ? 10 : undefined, + attributes: DEFAULT_ATTRIBUTES, }); }); },