File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1313- Fix duplicate error reporting on iOS with New Architecture ([ #5532 ] ( https://github.com/getsentry/sentry-react-native/pull/5532 ) )
1414- Fix for missing ` replay_id ` from metrics ([ #5483 ] ( https://github.com/getsentry/sentry-react-native/pull/5483 ) )
1515- Skip span ID check when standalone mode is enabled ([ #5493 ] ( https://github.com/getsentry/sentry-react-native/pull/5493 ) )
16+ - Fix traces not always being attached to replays with errors ([ #5538 ] ( https://github.com/getsentry/sentry-react-native/pull/5538 ) )
1617
1718### Dependencies
1819
Original file line number Diff line number Diff line change @@ -216,6 +216,12 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau
216216 debug . log (
217217 `[Sentry] ${ MOBILE_REPLAY_INTEGRATION_NAME } Captured recording replay ${ replayId } for event ${ event . event_id } .` ,
218218 ) ;
219+ // Add replay_id to error event contexts to link replays to events/traces
220+ event . contexts = event . contexts || { } ;
221+ event . contexts . replay = {
222+ ...event . contexts . replay ,
223+ replay_id : replayId ,
224+ } ;
219225 } else {
220226 // Check if there's an ongoing recording and update cache if found
221227 const recordingReplayId = NATIVE . getCurrentReplayId ( ) ;
@@ -224,6 +230,12 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau
224230 debug . log (
225231 `[Sentry] ${ MOBILE_REPLAY_INTEGRATION_NAME } assign already recording replay ${ recordingReplayId } for event ${ event . event_id } .` ,
226232 ) ;
233+ // Add replay_id to error event contexts to link replays to events/traces
234+ event . contexts = event . contexts || { } ;
235+ event . contexts . replay = {
236+ ...event . contexts . replay ,
237+ replay_id : recordingReplayId ,
238+ } ;
227239 } else {
228240 updateCachedReplayId ( null ) ;
229241 debug . log ( `[Sentry] ${ MOBILE_REPLAY_INTEGRATION_NAME } not sampled for event ${ event . event_id } .` ) ;
Original file line number Diff line number Diff line change @@ -258,6 +258,25 @@ describe('Mobile Replay Integration', () => {
258258
259259 expect ( mockCaptureReplay ) . toHaveBeenCalled ( ) ;
260260 } ) ;
261+
262+ it ( 'should add replay context to error events when replay is captured' , async ( ) => {
263+ const integration = mobileReplayIntegration ( ) ;
264+ const replayId = 'test-replay-id' ;
265+ mockCaptureReplay . mockResolvedValue ( replayId ) ;
266+
267+ const event : Event = {
268+ event_id : 'test-event-id' ,
269+ exception : {
270+ values : [ { type : 'Error' , value : 'Test error' } ] ,
271+ } ,
272+ } ;
273+ const hint : EventHint = { } ;
274+
275+ if ( integration . processEvent ) {
276+ const processedEvent = await integration . processEvent ( event , hint ) ;
277+ expect ( processedEvent . contexts ?. replay ?. replay_id ) . toBe ( replayId ) ;
278+ }
279+ } ) ;
261280 } ) ;
262281
263282 describe ( 'platform checks' , ( ) => {
You can’t perform that action at this time.
0 commit comments