@@ -3285,6 +3285,40 @@ class SentryClientTest {
32853285 assertTrue(terminated == true )
32863286 }
32873287
3288+ @Test
3289+ fun `sets replayId on frozen transaction baggage after captureReplay for error events` () {
3290+ val replayId = SentryId ()
3291+ fixture.sentryOptions.setReplayController(
3292+ object : ReplayController by NoOpReplayController .getInstance() {
3293+ override fun captureReplay (isTerminating : Boolean? ) {}
3294+ }
3295+ )
3296+ val sut = fixture.getSut()
3297+
3298+ val baggage = Baggage (fixture.sentryOptions.logger)
3299+ baggage.traceId = SentryId ().toString()
3300+ baggage.freeze()
3301+
3302+ val spanContext = SpanContext (" op.load" )
3303+ spanContext.baggage = baggage
3304+ val transaction = mock<ITransaction >()
3305+ whenever(transaction.spanContext).thenReturn(spanContext)
3306+ whenever(transaction.traceContext()).thenReturn(baggage.toTraceContext())
3307+
3308+ val scope = mock<IScope >()
3309+ whenever(scope.transaction).thenReturn(transaction)
3310+ whenever(scope.span).thenReturn(transaction)
3311+ whenever(scope.replayId).thenReturn(replayId)
3312+ whenever(scope.breadcrumbs).thenReturn(LinkedList <Breadcrumb >())
3313+ whenever(scope.extras).thenReturn(emptyMap())
3314+ whenever(scope.contexts).thenReturn(Contexts ())
3315+ whenever(scope.propagationContext).thenReturn(PropagationContext ())
3316+
3317+ sut.captureEvent(SentryEvent ().apply { exceptions = listOf (SentryException ()) }, scope)
3318+
3319+ assertEquals(replayId.toString(), baggage.getReplayId())
3320+ }
3321+
32883322 @Test
32893323 fun `cleans up replay folder for Backfillable replay events` () {
32903324 val dir = File (tmpDir.newFolder().absolutePath)
0 commit comments