Skip to content

Commit 45fab89

Browse files
authored
Merge branch 'main' into feat/promote-span-id-on-logs-to-property
2 parents fa9616c + 8107c75 commit 45fab89

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

.claude/settings.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(find:*)",
5+
"Bash(ls:*)",
6+
"Bash(git:*)",
7+
"Bash(git status:*)",
8+
"Bash(git log:*)",
9+
"Bash(git diff:*)",
10+
"Bash(git show:*)",
11+
"Bash(git branch:*)",
12+
"Bash(git remote:*)",
13+
"Bash(git tag:*)",
14+
"Bash(git stash list:*)",
15+
"Bash(git rev-parse:*)",
16+
"Bash(gh pr view:*)",
17+
"Bash(gh pr list:*)",
18+
"Bash(gh pr checks:*)",
19+
"Bash(gh pr diff:*)",
20+
"Bash(gh issue view:*)",
21+
"Bash(gh issue list:*)",
22+
"Bash(gh run view:*)",
23+
"Bash(gh run list:*)",
24+
"Bash(gh run logs:*)",
25+
"Bash(gh repo view:*)",
26+
"WebFetch(domain:github.com)",
27+
"WebFetch(domain:docs.sentry.io)",
28+
"WebFetch(domain:develop.sentry.dev)",
29+
"Bash(grep:*)",
30+
"Bash(mv:*)"
31+
],
32+
"deny": []
33+
}
34+
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- Added `io.sentry.ndk.sdk-name` Android manifest option to configure the native SDK's name ([#5027](https://github.com/getsentry/sentry-java/pull/5027))
88
- Replace `sentry.trace.parent_span_id` attribute with `spanId` property on `SentryLogEvent` ([#5040](https://github.com/getsentry/sentry-java/pull/5040))
99

10+
### Fixes
11+
12+
- Only attach user attributes to logs if `sendDefaultPii` is enabled ([#5036](https://github.com/getsentry/sentry-java/pull/5036))
13+
1014
### Dependencies
1115

1216
- Bump Native SDK from v0.12.2 to v0.12.3 ([#5012](https://github.com/getsentry/sentry-java/pull/5012))

sentry/src/main/java/io/sentry/logger/LoggerApi.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ private void captureLog(
243243
setServerName(attributes);
244244
}
245245

246-
setUser(attributes);
246+
if (scopes.getOptions().isSendDefaultPii()) {
247+
setUser(attributes);
248+
}
247249

248250
return attributes;
249251
}

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2913,11 +2913,12 @@ class ScopesTest {
29132913
}
29142914

29152915
@Test
2916-
fun `adds user fields to log attributes`() {
2916+
fun `adds user fields to log attributes if sendDefaultPii is true`() {
29172917
val (sut, mockClient) =
29182918
getEnabledScopes {
29192919
it.logs.isEnabled = true
29202920
it.distinctId = "distinctId"
2921+
it.isSendDefaultPii = true
29212922
}
29222923

29232924
sut.configureScope { scope ->
@@ -2951,6 +2952,37 @@ class ScopesTest {
29512952
)
29522953
}
29532954

2955+
@Test
2956+
fun `does not add user fields to log attributes by default`() {
2957+
val (sut, mockClient) =
2958+
getEnabledScopes {
2959+
it.logs.isEnabled = true
2960+
it.distinctId = "distinctId"
2961+
}
2962+
2963+
sut.configureScope { scope ->
2964+
scope.user =
2965+
User().also {
2966+
it.id = "usrid"
2967+
it.username = "usrname"
2968+
it.email = "user@sentry.io"
2969+
}
2970+
}
2971+
sut.logger().log(SentryLogLevel.WARN, "log message")
2972+
2973+
verify(mockClient)
2974+
.captureLog(
2975+
check {
2976+
assertEquals("log message", it.body)
2977+
2978+
assertNull(it.attributes?.get("user.id"))
2979+
assertNull(it.attributes?.get("user.name"))
2980+
assertNull(it.attributes?.get("user.email"))
2981+
},
2982+
anyOrNull(),
2983+
)
2984+
}
2985+
29542986
@Test
29552987
fun `unset user does provide distinct-id as user-id`() {
29562988
val (sut, mockClient) =

0 commit comments

Comments
 (0)