Skip to content

Commit 3099014

Browse files
authored
fix(session-replay): Leave captureReplay logic to the native implementation (#5243)
* fix(session-replay): Always try to record replay for hard crashes * Adds changelog * Improve logging * Remove unnecessary RN logic
1 parent 0b64753 commit 3099014

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Fixes .env file loading in Expo sourcemap uploads ([#5210](https://github.com/getsentry/sentry-react-native/pull/5210))
1919
- Fixes the issue with changing immutable metadata structure in the contructor of `ReactNativeClient`. This structure is getting re-created instead of being modified to ensure IP address is only inferred by Relay if `sendDefaultPii` is `true` ([#5202](https://github.com/getsentry/sentry-react-native/pull/5202))
2020
- Removes usage of deprecated `SafeAreaView` ([#5241](https://github.com/getsentry/sentry-react-native/pull/5241))
21+
- Fixes session replay recording for uncaught errors ([#5243](https://github.com/getsentry/sentry-react-native/pull/5243))
2122

2223
### Dependencies
2324

packages/core/src/js/replay/mobilereplay.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,20 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau
137137
return event;
138138
}
139139

140-
const recordingReplayId = NATIVE.getCurrentReplayId();
141-
if (recordingReplayId) {
142-
debug.log(
143-
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} assign already recording replay ${recordingReplayId} for event ${event.event_id}.`,
144-
);
145-
return event;
146-
}
147-
148140
const replayId = await NATIVE.captureReplay(isHardCrash(event));
149141
if (!replayId) {
150-
debug.log(`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} not sampled for event ${event.event_id}.`);
151-
return event;
142+
const recordingReplayId = NATIVE.getCurrentReplayId();
143+
if (recordingReplayId) {
144+
debug.log(
145+
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} assign already recording replay ${recordingReplayId} for event ${event.event_id}.`,
146+
);
147+
} else {
148+
debug.log(`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} not sampled for event ${event.event_id}.`);
149+
}
150+
} else {
151+
debug.log(
152+
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} Captured recording replay ${replayId} for event ${event.event_id}.`,
153+
);
152154
}
153155

154156
return event;

0 commit comments

Comments
 (0)