Skip to content

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Nov 20, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Add support for filtering replay captures on errors through a new beforeErrorSampling callback in mobileReplayIntegration. This allows developers to control which errors should trigger replay capture, similar to the JavaScript SDK's beforeErrorSampling implementation (see https://docs.sentry.io/platforms/javascript/session-replay/understanding-sessions/#ignore-certain-errors-for-error-sampling)

💡 Motivation and Context

Fixes #5392

Docs PR: getsentry/sentry-docs#15583

💚 How did you test it?

Manually, Unit tests

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 8c195b6

@antonis
Copy link
Contributor Author

antonis commented Nov 20, 2025

@sentry review

@antonis antonis marked this pull request as ready for review November 20, 2025 16:24
@github-actions
Copy link
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 391.84 ms 424.22 ms 32.38 ms
Size 43.94 MiB 48.87 MiB 4.93 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
161947d+dirty 349.27 ms 435.09 ms 85.82 ms
652f785+dirty 367.80 ms 390.71 ms 22.91 ms
8d89cc9+dirty 357.69 ms 415.79 ms 58.10 ms
c771b48+dirty 382.10 ms 409.02 ms 26.92 ms
459a438+dirty 359.50 ms 390.53 ms 31.03 ms
e07935d+dirty 380.10 ms 377.48 ms -2.62 ms
b7aa1aa+dirty 281.02 ms 317.53 ms 36.51 ms
0d6e618+dirty 369.02 ms 387.69 ms 18.67 ms
c08359e+dirty 406.04 ms 428.87 ms 22.83 ms
526494a+dirty 361.10 ms 410.84 ms 49.74 ms

App size

Revision Plain With Sentry Diff
161947d+dirty 7.15 MiB 8.43 MiB 1.28 MiB
652f785+dirty 43.94 MiB 48.82 MiB 4.88 MiB
8d89cc9+dirty 7.15 MiB 8.41 MiB 1.26 MiB
c771b48+dirty 43.94 MiB 48.85 MiB 4.91 MiB
459a438+dirty 7.15 MiB 8.42 MiB 1.27 MiB
e07935d+dirty 43.94 MiB 48.82 MiB 4.88 MiB
b7aa1aa+dirty 7.15 MiB 8.46 MiB 1.31 MiB
0d6e618+dirty 43.94 MiB 48.82 MiB 4.88 MiB
c08359e+dirty 7.15 MiB 8.42 MiB 1.27 MiB
526494a+dirty 43.94 MiB 48.82 MiB 4.88 MiB

@github-actions
Copy link
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 427.40 ms 450.92 ms 23.52 ms
Size 43.75 MiB 48.04 MiB 4.29 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
77061ed+dirty 369.55 ms 408.35 ms 38.80 ms
59f3a84+dirty 382.16 ms 376.45 ms -5.71 ms
46da307 455.92 ms 443.79 ms -12.13 ms
652f785+dirty 401.02 ms 420.60 ms 19.58 ms
1bea095+dirty 401.42 ms 426.93 ms 25.52 ms
c771b48+dirty 412.79 ms 431.96 ms 19.17 ms
e07935d+dirty 448.82 ms 489.10 ms 40.29 ms
90afdd3+dirty 375.94 ms 377.52 ms 1.58 ms
b7aa1aa+dirty 324.73 ms 327.76 ms 3.03 ms
0d6e618+dirty 414.00 ms 416.90 ms 2.90 ms

App size

Revision Plain With Sentry Diff
77061ed+dirty 17.75 MiB 19.68 MiB 1.94 MiB
59f3a84+dirty 17.75 MiB 19.70 MiB 1.95 MiB
46da307 17.75 MiB 19.68 MiB 1.93 MiB
652f785+dirty 43.75 MiB 47.99 MiB 4.24 MiB
1bea095+dirty 17.75 MiB 19.70 MiB 1.95 MiB
c771b48+dirty 43.75 MiB 48.02 MiB 4.27 MiB
e07935d+dirty 43.75 MiB 47.99 MiB 4.24 MiB
90afdd3+dirty 17.75 MiB 19.70 MiB 1.95 MiB
b7aa1aa+dirty 17.75 MiB 19.75 MiB 2.00 MiB
0d6e618+dirty 43.75 MiB 47.99 MiB 4.24 MiB

@github-actions
Copy link
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.72 ms 1219.00 ms 1.28 ms
Size 3.41 MiB 4.59 MiB 1.18 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e07935d+dirty 1217.37 ms 1211.44 ms -5.93 ms
534ba8c+dirty 1230.22 ms 1231.18 ms 0.96 ms
ec14be7+dirty 1234.64 ms 1245.54 ms 10.90 ms
98f632c+dirty 1236.40 ms 1241.62 ms 5.22 ms
266bc7e+dirty 1190.56 ms 1191.47 ms 0.91 ms
bc9680d+dirty 1221.41 ms 1241.47 ms 20.06 ms
ea3e26e+dirty 1229.13 ms 1228.46 ms -0.67 ms
7091004+dirty 1215.54 ms 1215.58 ms 0.04 ms
bfe454a+dirty 1235.33 ms 1243.12 ms 7.79 ms
73f2455+dirty 1213.49 ms 1211.96 ms -1.53 ms

App size

Revision Plain With Sentry Diff
e07935d+dirty 3.41 MiB 4.58 MiB 1.17 MiB
534ba8c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
ec14be7+dirty 2.63 MiB 3.98 MiB 1.34 MiB
98f632c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
266bc7e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
bc9680d+dirty 2.63 MiB 3.81 MiB 1.18 MiB
ea3e26e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
7091004+dirty 3.41 MiB 4.57 MiB 1.16 MiB
bfe454a+dirty 2.63 MiB 3.98 MiB 1.34 MiB
73f2455+dirty 3.41 MiB 4.58 MiB 1.17 MiB

@github-actions
Copy link
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.31 ms 1217.89 ms 0.57 ms
Size 3.41 MiB 4.59 MiB 1.18 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e07935d+dirty 1225.85 ms 1227.72 ms 1.87 ms
534ba8c+dirty 1225.00 ms 1237.43 ms 12.43 ms
ec14be7+dirty 1229.62 ms 1230.53 ms 0.91 ms
98f632c+dirty 1221.38 ms 1229.26 ms 7.88 ms
266bc7e+dirty 1217.73 ms 1222.30 ms 4.57 ms
bc9680d+dirty 1228.57 ms 1233.64 ms 5.07 ms
ea3e26e+dirty 1216.61 ms 1214.15 ms -2.47 ms
7091004+dirty 1219.11 ms 1225.98 ms 6.87 ms
bfe454a+dirty 1231.82 ms 1239.98 ms 8.16 ms
73f2455+dirty 1219.85 ms 1218.29 ms -1.56 ms

App size

Revision Plain With Sentry Diff
e07935d+dirty 3.41 MiB 4.58 MiB 1.17 MiB
534ba8c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
ec14be7+dirty 3.19 MiB 4.54 MiB 1.36 MiB
98f632c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
266bc7e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
bc9680d+dirty 3.19 MiB 4.38 MiB 1.19 MiB
ea3e26e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
7091004+dirty 3.41 MiB 4.57 MiB 1.16 MiB
bfe454a+dirty 3.19 MiB 4.54 MiB 1.36 MiB
73f2455+dirty 3.41 MiB 4.58 MiB 1.17 MiB

try {
if (initOptions.beforeErrorSampling(event, hint) === false) {
debug.log(
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} skipped due to beforeErrorSampling for event ${event.event_id}.`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did a great naming log! But I think using skipped may give the impression that the replay will not be sent afterward, what do you think of the following suggestion?

Suggested change
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} skipped due to beforeErrorSampling for event ${event.event_id}.`,
`[Sentry] ${MOBILE_REPLAY_INTEGRATION_NAME} not sent; beforeErrorSampling conditions not met for event ${event.event_id}.`,

Copy link
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a suggestion for the log phrase, but other than that, LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow beforeErrorSampling on mobileReplayIntegration

3 participants