Skip to content

Commit 06db34f

Browse files
Fix: Don't set lastEventId for transactions (#1727)
Fixes #1709
1 parent 8f54d89 commit 06db34f

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* Fix: Don't set lastEventId for transactions (#1727)
6+
57
## 5.2.0-beta.3
68

79
* Fix: Check at runtime if AndroidX.Core is available (#1718)

sentry/src/main/java/io/sentry/Hub.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ public boolean isEnabled() {
146146
options.getLogger().log(SentryLevel.ERROR, "Error while capturing envelope.", e);
147147
}
148148
}
149-
this.lastEventId = sentryId;
150149
return sentryId;
151150
}
152151

@@ -576,7 +575,6 @@ public void flush(long timeoutMillis) {
576575
}
577576
}
578577
}
579-
this.lastEventId = sentryId;
580578
return sentryId;
581579
}
582580

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,21 @@ class HubTest {
927927
sut.captureEnvelope(envelope)
928928
verify(mockClient).captureEnvelope(any(), anyOrNull())
929929
}
930+
931+
@Test
932+
fun `when captureEnvelope is called, lastEventId is not set`() {
933+
val options = SentryOptions().apply {
934+
dsn = "https://[email protected]/proj"
935+
setSerializer(mock())
936+
}
937+
val sut = Hub(options)
938+
val mockClient = mock<ISentryClient>()
939+
sut.bindClient(mockClient)
940+
whenever(mockClient.captureEnvelope(any(), anyOrNull())).thenReturn(SentryId())
941+
val envelope = SentryEnvelope(SentryId(UUID.randomUUID()), null, setOf())
942+
sut.captureEnvelope(envelope)
943+
assertEquals(SentryId.EMPTY_ID, sut.lastEventId)
944+
}
930945
//endregion
931946

932947
//region startSession tests
@@ -1078,6 +1093,22 @@ class HubTest {
10781093
verify(mockClient).captureTransaction(any(), eq(traceState), any(), eq(null))
10791094
}
10801095

1096+
@Test
1097+
fun `when captureTransaction is called, lastEventId is not set`() {
1098+
val options = SentryOptions().apply {
1099+
dsn = "https://[email protected]/proj"
1100+
setSerializer(mock())
1101+
}
1102+
val sut = Hub(options)
1103+
val mockClient = mock<ISentryClient>()
1104+
sut.bindClient(mockClient)
1105+
whenever(mockClient.captureTransaction(anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(SentryId())
1106+
1107+
val sentryTracer = SentryTracer(TransactionContext("name", "op", true), sut)
1108+
sentryTracer.finish()
1109+
assertEquals(SentryId.EMPTY_ID, sut.lastEventId)
1110+
}
1111+
10811112
@Test
10821113
fun `when captureTransaction and transaction is not finished, captureTransaction on the client should not be called`() {
10831114
val options = SentryOptions()

0 commit comments

Comments
 (0)