Skip to content

Commit

Permalink
Fix: Don't set lastEventId for transactions (#1727)
Browse files Browse the repository at this point in the history
Fixes #1709
  • Loading branch information
maciejwalkowiak authored Sep 16, 2021
1 parent 8f54d89 commit 06db34f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Fix: Don't set lastEventId for transactions (#1727)

## 5.2.0-beta.3

* Fix: Check at runtime if AndroidX.Core is available (#1718)
Expand Down
2 changes: 0 additions & 2 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public boolean isEnabled() {
options.getLogger().log(SentryLevel.ERROR, "Error while capturing envelope.", e);
}
}
this.lastEventId = sentryId;
return sentryId;
}

Expand Down Expand Up @@ -576,7 +575,6 @@ public void flush(long timeoutMillis) {
}
}
}
this.lastEventId = sentryId;
return sentryId;
}

Expand Down
31 changes: 31 additions & 0 deletions sentry/src/test/java/io/sentry/HubTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,21 @@ class HubTest {
sut.captureEnvelope(envelope)
verify(mockClient).captureEnvelope(any(), anyOrNull())
}

@Test
fun `when captureEnvelope is called, lastEventId is not set`() {
val options = SentryOptions().apply {
dsn = "https://[email protected]/proj"
setSerializer(mock())
}
val sut = Hub(options)
val mockClient = mock<ISentryClient>()
sut.bindClient(mockClient)
whenever(mockClient.captureEnvelope(any(), anyOrNull())).thenReturn(SentryId())
val envelope = SentryEnvelope(SentryId(UUID.randomUUID()), null, setOf())
sut.captureEnvelope(envelope)
assertEquals(SentryId.EMPTY_ID, sut.lastEventId)
}
//endregion

//region startSession tests
Expand Down Expand Up @@ -1078,6 +1093,22 @@ class HubTest {
verify(mockClient).captureTransaction(any(), eq(traceState), any(), eq(null))
}

@Test
fun `when captureTransaction is called, lastEventId is not set`() {
val options = SentryOptions().apply {
dsn = "https://[email protected]/proj"
setSerializer(mock())
}
val sut = Hub(options)
val mockClient = mock<ISentryClient>()
sut.bindClient(mockClient)
whenever(mockClient.captureTransaction(anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(SentryId())

val sentryTracer = SentryTracer(TransactionContext("name", "op", true), sut)
sentryTracer.finish()
assertEquals(SentryId.EMPTY_ID, sut.lastEventId)
}

@Test
fun `when captureTransaction and transaction is not finished, captureTransaction on the client should not be called`() {
val options = SentryOptions()
Expand Down

0 comments on commit 06db34f

Please sign in to comment.