Skip to content

Commit f8dd6ed

Browse files
committed
fix(e2e): Fix captureReplay e2e failure on iOS
1 parent 33d1129 commit f8dd6ed

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

dev-packages/e2e-tests/maestro/utils/sentryApi.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ switch (fetch) {
6363
}
6464
case 'replay': {
6565
const event = json(fetchFromSentry(`${baseUrl}/events/${eventId}/json/`));
66-
const replayId = event._dsc.replay_id.replace(/\-/g, '');
66+
const replayIdRaw = event._dsc?.replay_id;
67+
if (!replayIdRaw) {
68+
console.error('Event DSC:', JSON.stringify(event._dsc, null, 2));
69+
throw new Error(`Event ${eventId} does not have a replay_id in DSC. Replay might not be configured properly. Check that replaysOnErrorSampleRate or replaysSessionSampleRate is set.`);
70+
}
71+
const replayId = replayIdRaw.replace(/\-/g, '');
6772
const replay = json(fetchFromSentry(`${baseUrl}/replays/${replayId}/`));
6873
const segment = fetchFromSentry(`${baseUrl}/replays/${replayId}/videos/0/`);
6974

dev-packages/e2e-tests/patch-scripts/rn.patch.app.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,23 @@ import * as Sentry from '@sentry/react-native';
2323
import { EndToEndTestsScreen } from 'sentry-react-native-e2e-tests';
2424
import { LaunchArguments } from "react-native-launch-arguments";
2525
26+
const launchArgs = LaunchArguments.value();
27+
2628
Sentry.init({
2729
release: '${SENTRY_RELEASE}',
2830
dist: '${SENTRY_DIST}',
2931
dsn: 'https://1df17bd4e543fdb31351dee1768bb679@o447951.ingest.sentry.io/5428561',
30-
_experiments: {
31-
replaysOnErrorSampleRate: LaunchArguments.value().replaysOnErrorSampleRate,
32-
},
32+
replaysOnErrorSampleRate: launchArgs.replaysOnErrorSampleRate,
33+
replaysSessionSampleRate: launchArgs.replaysSessionSampleRate,
3334
integrations: [
3435
Sentry.mobileReplayIntegration(),
3536
Sentry.feedbackIntegration({
3637
enableTakeScreenshot: true,
3738
}),
3839
],
3940
});
41+
42+
console.log('[E2E] Initialized with replaysOnErrorSampleRate:', launchArgs.replaysOnErrorSampleRate);
4043
`;
4144
const e2eComponentPatch = '<EndToEndTestsScreen />';
4245
const lastImportRex = /^([^]*)(import\s+[^;]*?;$)/m;

0 commit comments

Comments
 (0)