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 3278829

@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

github-actions bot commented Nov 20, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 362.04 ms 403.53 ms 41.49 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

Previous results on branch: antonis/replay-beforeErrorSampling

Startup times

Revision Plain With Sentry Diff
bca7030+dirty 391.84 ms 424.22 ms 32.38 ms

App size

Revision Plain With Sentry Diff
bca7030+dirty 43.94 MiB 48.87 MiB 4.93 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 413.65 ms 418.08 ms 4.43 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

Previous results on branch: antonis/replay-beforeErrorSampling

Startup times

Revision Plain With Sentry Diff
bca7030+dirty 427.40 ms 450.92 ms 23.52 ms

App size

Revision Plain With Sentry Diff
bca7030+dirty 43.75 MiB 48.04 MiB 4.29 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1211.86 ms 1215.51 ms 3.65 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

Previous results on branch: antonis/replay-beforeErrorSampling

Startup times

Revision Plain With Sentry Diff
bca7030+dirty 1217.72 ms 1219.00 ms 1.28 ms

App size

Revision Plain With Sentry Diff
bca7030+dirty 3.41 MiB 4.59 MiB 1.18 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1222.05 ms 1217.59 ms -4.46 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

Previous results on branch: antonis/replay-beforeErrorSampling

Startup times

Revision Plain With Sentry Diff
bca7030+dirty 1217.31 ms 1217.89 ms 0.57 ms

App size

Revision Plain With Sentry Diff
bca7030+dirty 3.41 MiB 4.59 MiB 1.18 MiB

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!

Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>
@antonis antonis merged commit 9b50d32 into main Nov 24, 2025
91 of 92 checks passed
@antonis antonis deleted the antonis/replay-beforeErrorSampling branch November 24, 2025 09:04
antonis added a commit to getsentry/sentry-docs that referenced this pull request Nov 24, 2025
<!-- Use this checklist to make sure your PR is ready for merge. You may
delete any sections you don't need. -->

## DESCRIBE YOUR PR
*Tell us what you're changing and why. If your PR **resolves an issue**,
please link it so it closes automatically.*

## IS YOUR CHANGE URGENT?  

Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [ ] None: Not urgent, can wait up to 1 week+

Merge after getsentry/sentry-react-native#5393
is released

## SLA

- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!

## PRE-MERGE CHECKLIST

*Make sure you've checked the following before merging your changes:*

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

## LEGAL BOILERPLATE

<!-- Sentry employees and contractors can delete or ignore this section.
-->

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

## EXTRA RESOURCES

- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
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