diff --git a/packages/core/src/logs/exports.ts b/packages/core/src/logs/exports.ts index f44817c13715..176cdcd657b0 100644 --- a/packages/core/src/logs/exports.ts +++ b/packages/core/src/logs/exports.ts @@ -138,14 +138,12 @@ export function _INTERNAL_captureLog( ...beforeLog.attributes, }; - const { user } = getMergedScopeData(currentScope); - // Only attach user to log attributes if sendDefaultPii is enabled - if (client.getOptions().sendDefaultPii) { - const { id, email, username } = user; - setLogAttribute(processedLogAttributes, 'user.id', id, false); - setLogAttribute(processedLogAttributes, 'user.email', email, false); - setLogAttribute(processedLogAttributes, 'user.name', username, false); - } + const { + user: { id, email, username }, + } = getMergedScopeData(currentScope); + setLogAttribute(processedLogAttributes, 'user.id', id, false); + setLogAttribute(processedLogAttributes, 'user.email', email, false); + setLogAttribute(processedLogAttributes, 'user.name', username, false); setLogAttribute(processedLogAttributes, 'sentry.release', release); setLogAttribute(processedLogAttributes, 'sentry.environment', environment); diff --git a/packages/core/test/lib/logs/exports.test.ts b/packages/core/test/lib/logs/exports.test.ts index 8c1fe4d8e76f..3ba9f59b50d3 100644 --- a/packages/core/test/lib/logs/exports.test.ts +++ b/packages/core/test/lib/logs/exports.test.ts @@ -377,11 +377,10 @@ describe('_INTERNAL_captureLog', () => { }); describe('user functionality', () => { - it('includes user data in log attributes when sendDefaultPii is enabled', () => { + it('includes user data in log attributes', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableLogs: true }, - sendDefaultPii: true, }); const client = new TestClient(options); const scope = new Scope(); @@ -410,26 +409,6 @@ describe('_INTERNAL_captureLog', () => { }); }); - it('does not include user data in log attributes when sendDefaultPii is disabled', () => { - const options = getDefaultTestClientOptions({ - dsn: PUBLIC_DSN, - _experiments: { enableLogs: true }, - sendDefaultPii: false, - }); - const client = new TestClient(options); - const scope = new Scope(); - scope.setUser({ - id: '123', - email: 'user@example.com', - username: 'testuser', - }); - - _INTERNAL_captureLog({ level: 'info', message: 'test log without user' }, client, scope); - - const logAttributes = _INTERNAL_getLogBuffer(client)?.[0]?.attributes; - expect(logAttributes).toEqual({}); - }); - it('includes partial user data when only some fields are available', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN,