Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove userId from baggage due to PII #2157

Merged
merged 4 commits into from Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

### Features

Expand Down
6 changes: 5 additions & 1 deletion sentry/src/main/java/io/sentry/TraceContext.java
Expand Up @@ -56,17 +56,21 @@ public final class TraceContext implements JsonUnknown, JsonSerializable {
final @Nullable User user,
final @NotNull SentryOptions sentryOptions,
final @Nullable TracesSamplingDecision samplingDecision) {
// user_id isn't part of the dynamic sampling context right now because
// of PII concerns.
// https://develop.sentry.dev/sdk/performance/dynamic-sampling-context/#the-temporal-problem
this(
transaction.getSpanContext().getTraceId(),
new Dsn(sentryOptions.getDsn()).getPublicKey(),
sentryOptions.getRelease(),
sentryOptions.getEnvironment(),
getUserId(sentryOptions, user),
null, // getUserId(sentryOptions, user),
user != null ? getSegment(user) : null,
transaction.getName(),
sampleRateToString(sampleRate(samplingDecision)));
}

@SuppressWarnings("UnusedMethod")
private static @Nullable String getUserId(
final @NotNull SentryOptions options, final @Nullable User user) {
if (options.isSendDefaultPii() && user != null) {
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/test/java/io/sentry/SentryTracerTest.kt
Expand Up @@ -496,7 +496,7 @@ class SentryTracerTest {
assertEquals("environment", it.environment)
assertEquals("release@3.0.0", it.release)
assertEquals(transaction.name, it.transaction)
assertEquals("user-id", it.userId)
// assertEquals("user-id", it.userId)
assertEquals("pro", it.userSegment)
}
}
Expand Down Expand Up @@ -569,7 +569,7 @@ class SentryTracerTest {
assertTrue(it.value.contains("sentry-release=1.0.99-rc.7,"))
assertTrue(it.value.contains("sentry-environment=production,"))
assertTrue(it.value.contains("sentry-transaction=name,"))
assertTrue(it.value.contains("sentry-user_id=userId12345,"))
// assertTrue(it.value.contains("sentry-user_id=userId12345,"))
assertTrue(it.value.contains("sentry-user_segment=pro$".toRegex()))
}
}
Expand Down