Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- When merging tombstones with Native SDK, use the tombstone message if the Native SDK didn't explicitly provide one. ([#5095](https://github.com/getsentry/sentry-java/pull/5095))
- Fix thread leak caused by eager creation of `SentryExecutorService` in `SentryOptions` ([#5093](https://github.com/getsentry/sentry-java/pull/5093))
- There were cases where we created options that ended up unused but we failed to clean those up.
- Attach user attributes to logs and metrics regardless of `sendDefaultPii` ([#5099](https://github.com/getsentry/sentry-java/pull/5099))
- No longer log a warning if a logging integration cannot initialize Sentry due to missing DSN ([#5075](https://github.com/getsentry/sentry-java/pull/5075))
- While this may have been useful to some, it caused lots of confusion.
- Session Replay: Add `androidx.camera.view.PreviewView` to default `maskedViewClasses` to mask camera previews by default. ([#5097](https://github.com/getsentry/sentry-java/pull/5097))
Expand Down
4 changes: 1 addition & 3 deletions sentry/src/main/java/io/sentry/logger/LoggerApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ private void captureLog(
setServerName(attributes);
}

if (scopes.getOptions().isSendDefaultPii()) {
setUser(attributes);
}
setUser(attributes);

return attributes;
}
Expand Down
4 changes: 1 addition & 3 deletions sentry/src/main/java/io/sentry/metrics/MetricsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ private void captureMetrics(
setServerName(attributes);
}

if (scopes.getOptions().isSendDefaultPii()) {
setUser(attributes);
}
setUser(attributes);

return attributes;
}
Expand Down
46 changes: 26 additions & 20 deletions sentry/src/test/java/io/sentry/ScopesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ class ScopesTest {
}

@Test
fun `does not add user fields to log attributes by default`() {
fun `adds user fields to log attributes even if sendDefaultPii is false`() {
val (sut, mockClient) =
getEnabledScopes {
it.logs.isEnabled = true
Expand All @@ -2975,9 +2975,17 @@ class ScopesTest {
check {
assertEquals("log message", it.body)

assertNull(it.attributes?.get("user.id"))
assertNull(it.attributes?.get("user.name"))
assertNull(it.attributes?.get("user.email"))
val userId = it.attributes?.get("user.id")!!
assertEquals("usrid", userId.value)
assertEquals("string", userId.type)

val userName = it.attributes?.get("user.name")!!
assertEquals("usrname", userName.value)
assertEquals("string", userName.type)

val userEmail = it.attributes?.get("user.email")!!
assertEquals("user@sentry.io", userEmail.value)
assertEquals("string", userEmail.type)
},
anyOrNull(),
)
Expand All @@ -2988,7 +2996,6 @@ class ScopesTest {
val (sut, mockClient) =
getEnabledScopes {
it.logs.isEnabled = true
it.isSendDefaultPii = true
it.distinctId = "distinctId"
}

Expand All @@ -3012,7 +3019,6 @@ class ScopesTest {
val (sut, mockClient) =
getEnabledScopes {
it.logs.isEnabled = true
it.isSendDefaultPii = true
it.distinctId = null
}

Expand Down Expand Up @@ -3919,7 +3925,7 @@ class ScopesTest {
}

@Test
fun `does not add user fields to metric attributes by default`() {
fun `adds user fields to metric attributes even if sendDefaultPii is false`() {
val (sut, mockClient) = getEnabledScopes { it.distinctId = "distinctId" }

sut.configureScope { scope ->
Expand All @@ -3937,9 +3943,17 @@ class ScopesTest {
check {
assertEquals("metric name", it.name)

assertNull(it.attributes?.get("user.id"))
assertNull(it.attributes?.get("user.name"))
assertNull(it.attributes?.get("user.email"))
val userId = it.attributes?.get("user.id")!!
assertEquals("usrid", userId.value)
assertEquals("string", userId.type)

val userName = it.attributes?.get("user.name")!!
assertEquals("usrname", userName.value)
assertEquals("string", userName.type)

val userEmail = it.attributes?.get("user.email")!!
assertEquals("user@sentry.io", userEmail.value)
assertEquals("string", userEmail.type)
},
anyOrNull(),
anyOrNull(),
Expand All @@ -3948,11 +3962,7 @@ class ScopesTest {

@Test
fun `unset user does provide distinct-id as user-id for metrics`() {
val (sut, mockClient) =
getEnabledScopes {
it.isSendDefaultPii = true
it.distinctId = "distinctId"
}
val (sut, mockClient) = getEnabledScopes { it.distinctId = "distinctId" }

sut.metrics().count("metric name")

Expand All @@ -3972,11 +3982,7 @@ class ScopesTest {

@Test
fun `unset user does provide null user-id when distinct-id is missing for metrics`() {
val (sut, mockClient) =
getEnabledScopes {
it.isSendDefaultPii = true
it.distinctId = null
}
val (sut, mockClient) = getEnabledScopes { it.distinctId = null }

sut.metrics().count("metric name")

Expand Down
Loading