Skip to content

Commit a0a0b15

Browse files
authored
Remove userId from baggage due to PII (#2157)
1 parent efabc19 commit a0a0b15

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Only send userid in Dynamic Sampling Context if sendDefaultPii is true ([#2147](https://github.com/getsentry/sentry-java/pull/2147))
8+
- Remove userId from baggage due to PII ([#2157](https://github.com/getsentry/sentry-java/pull/2157))
89

910
### Features
1011

sentry/src/main/java/io/sentry/TraceContext.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,21 @@ public final class TraceContext implements JsonUnknown, JsonSerializable {
5656
final @Nullable User user,
5757
final @NotNull SentryOptions sentryOptions,
5858
final @Nullable TracesSamplingDecision samplingDecision) {
59+
// user_id isn't part of the dynamic sampling context right now because
60+
// of PII concerns.
61+
// https://develop.sentry.dev/sdk/performance/dynamic-sampling-context/#the-temporal-problem
5962
this(
6063
transaction.getSpanContext().getTraceId(),
6164
new Dsn(sentryOptions.getDsn()).getPublicKey(),
6265
sentryOptions.getRelease(),
6366
sentryOptions.getEnvironment(),
64-
getUserId(sentryOptions, user),
67+
null, // getUserId(sentryOptions, user),
6568
user != null ? getSegment(user) : null,
6669
transaction.getName(),
6770
sampleRateToString(sampleRate(samplingDecision)));
6871
}
6972

73+
@SuppressWarnings("UnusedMethod")
7074
private static @Nullable String getUserId(
7175
final @NotNull SentryOptions options, final @Nullable User user) {
7276
if (options.isSendDefaultPii() && user != null) {

sentry/src/test/java/io/sentry/SentryTracerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class SentryTracerTest {
496496
assertEquals("environment", it.environment)
497497
assertEquals("[email protected]", it.release)
498498
assertEquals(transaction.name, it.transaction)
499-
assertEquals("user-id", it.userId)
499+
// assertEquals("user-id", it.userId)
500500
assertEquals("pro", it.userSegment)
501501
}
502502
}
@@ -569,7 +569,7 @@ class SentryTracerTest {
569569
assertTrue(it.value.contains("sentry-release=1.0.99-rc.7,"))
570570
assertTrue(it.value.contains("sentry-environment=production,"))
571571
assertTrue(it.value.contains("sentry-transaction=name,"))
572-
assertTrue(it.value.contains("sentry-user_id=userId12345,"))
572+
// assertTrue(it.value.contains("sentry-user_id=userId12345,"))
573573
assertTrue(it.value.contains("sentry-user_segment=pro$".toRegex()))
574574
}
575575
}

0 commit comments

Comments
 (0)