From bacaf6945a720d9f9a1d0ee53e32381fa84bdd5c Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 9 Jun 2025 17:24:34 -0400 Subject: [PATCH 1/2] feat(core): Don't gate user on logs with `sendDefaultPii` --- packages/core/src/logs/exports.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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); From 9d564a08844cb93f730cc4050aab192f25066903 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 11 Jun 2025 11:49:50 -0400 Subject: [PATCH 2/2] fix tests --- packages/core/test/lib/logs/exports.test.ts | 23 +-------------------- 1 file changed, 1 insertion(+), 22 deletions(-) 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,