Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ class SentryTimberTreeTest {
verify(fixture.scopes).captureEvent(check { assertEquals("tag", it.getTag("TimberTag")) })
}

@Test
fun `Tree captures an event with TimberTag tag for debug events`() {
val sut = fixture.getSut(minEventLevel = SentryLevel.INFO)
Timber.plant(sut)
// only available thru static class
Timber.tag("infoTag").i("message")
verify(fixture.scopes).captureEvent(check { assertEquals("infoTag", it.getTag("TimberTag")) })
}

@Test
fun `Tree captures an event without TimberTag tag`() {
val sut = fixture.getSut()
Comment on lines +143 to 153
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SentryTimberTree.log() fails to capture events when Timber's chained API is used, only setting pendingTag.
Severity: HIGH | Confidence: 1.00

🔍 Detailed Analysis

When Timber's chained API, such as Timber.tag("tag").i("message"), is used, the SentryTimberTree.log(priority: Int, tag: String?, message: String, t: Throwable?) method is invoked. This method only sets the pendingTag in a ThreadLocal but does not proceed with the actual logging by calling super.log() or logWithSentry(). Consequently, no event is captured by Sentry for these chained logging calls, leading to missing log data.

💡 Suggested Fix

Modify SentryTimberTree.log() to invoke the actual logging logic (e.g., logWithSentry()) after setting the pendingTag when Timber's chained API is used.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt#L139-L153

Potential issue: When Timber's chained API, such as `Timber.tag("tag").i("message")`, is
used, the `SentryTimberTree.log(priority: Int, tag: String?, message: String, t:
Throwable?)` method is invoked. This method only sets the `pendingTag` in a ThreadLocal
but does not proceed with the actual logging by calling `super.log()` or
`logWithSentry()`. Consequently, no event is captured by Sentry for these chained
logging calls, leading to missing log data.

Did we get this right? 👍 / 👎 to inform future reviews.

Expand Down
Loading