Skip to content

Commit 66436bc

Browse files
authored
feat(core): Don't gate user on logs with sendDefaultPii (#16527)
ref getsentry/sentry-docs#13974
1 parent a26bdaf commit 66436bc

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

packages/core/src/logs/exports.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,12 @@ export function _INTERNAL_captureLog(
138138
...beforeLog.attributes,
139139
};
140140

141-
const { user } = getMergedScopeData(currentScope);
142-
// Only attach user to log attributes if sendDefaultPii is enabled
143-
if (client.getOptions().sendDefaultPii) {
144-
const { id, email, username } = user;
145-
setLogAttribute(processedLogAttributes, 'user.id', id, false);
146-
setLogAttribute(processedLogAttributes, 'user.email', email, false);
147-
setLogAttribute(processedLogAttributes, 'user.name', username, false);
148-
}
141+
const {
142+
user: { id, email, username },
143+
} = getMergedScopeData(currentScope);
144+
setLogAttribute(processedLogAttributes, 'user.id', id, false);
145+
setLogAttribute(processedLogAttributes, 'user.email', email, false);
146+
setLogAttribute(processedLogAttributes, 'user.name', username, false);
149147

150148
setLogAttribute(processedLogAttributes, 'sentry.release', release);
151149
setLogAttribute(processedLogAttributes, 'sentry.environment', environment);

packages/core/test/lib/logs/exports.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,10 @@ describe('_INTERNAL_captureLog', () => {
377377
});
378378

379379
describe('user functionality', () => {
380-
it('includes user data in log attributes when sendDefaultPii is enabled', () => {
380+
it('includes user data in log attributes', () => {
381381
const options = getDefaultTestClientOptions({
382382
dsn: PUBLIC_DSN,
383383
_experiments: { enableLogs: true },
384-
sendDefaultPii: true,
385384
});
386385
const client = new TestClient(options);
387386
const scope = new Scope();
@@ -410,26 +409,6 @@ describe('_INTERNAL_captureLog', () => {
410409
});
411410
});
412411

413-
it('does not include user data in log attributes when sendDefaultPii is disabled', () => {
414-
const options = getDefaultTestClientOptions({
415-
dsn: PUBLIC_DSN,
416-
_experiments: { enableLogs: true },
417-
sendDefaultPii: false,
418-
});
419-
const client = new TestClient(options);
420-
const scope = new Scope();
421-
scope.setUser({
422-
id: '123',
423-
email: 'user@example.com',
424-
username: 'testuser',
425-
});
426-
427-
_INTERNAL_captureLog({ level: 'info', message: 'test log without user' }, client, scope);
428-
429-
const logAttributes = _INTERNAL_getLogBuffer(client)?.[0]?.attributes;
430-
expect(logAttributes).toEqual({});
431-
});
432-
433412
it('includes partial user data when only some fields are available', () => {
434413
const options = getDefaultTestClientOptions({
435414
dsn: PUBLIC_DSN,

0 commit comments

Comments
 (0)