Repository navigation
fix: Fix default values and dictionary values for session replay options - #5210
Conversation
|
cc @kahest so you know this PR exists. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5210 +/- ##
=============================================
+ Coverage 92.746% 92.902% +0.155%
=============================================
Files 677 680 +3
Lines 84695 85368 +673
Branches 30806 30982 +176
=============================================
+ Hits 78552 79309 +757
+ Misses 6041 5957 -84
Partials 102 102
... and 19 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1ee5a37 | 1209.37 ms | 1222.04 ms | 12.68 ms |
| 7f691b5 | 1233.94 ms | 1243.80 ms | 9.86 ms |
| e070f8a | 1236.47 ms | 1250.50 ms | 14.03 ms |
| c8dbe73 | 1215.37 ms | 1237.31 ms | 21.94 ms |
| aeec206 | 1229.27 ms | 1253.70 ms | 24.43 ms |
| c810e58 | 1221.57 ms | 1250.45 ms | 28.88 ms |
| 034be1c | 1222.67 ms | 1236.22 ms | 13.55 ms |
| 533859f | 1237.78 ms | 1249.76 ms | 11.98 ms |
| 4977fbc | 1231.55 ms | 1239.80 ms | 8.25 ms |
| 742d4b6 | 1204.00 ms | 1217.90 ms | 13.90 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1ee5a37 | 21.58 KiB | 670.39 KiB | 648.81 KiB |
| 7f691b5 | 20.76 KiB | 420.55 KiB | 399.79 KiB |
| e070f8a | 21.58 KiB | 546.20 KiB | 524.62 KiB |
| c8dbe73 | 21.58 KiB | 615.91 KiB | 594.33 KiB |
| aeec206 | 20.76 KiB | 434.88 KiB | 414.12 KiB |
| c810e58 | 22.32 KiB | 761.10 KiB | 738.78 KiB |
| 034be1c | 20.76 KiB | 436.66 KiB | 415.90 KiB |
| 533859f | 22.85 KiB | 408.84 KiB | 386.00 KiB |
| 4977fbc | 20.76 KiB | 419.86 KiB | 399.10 KiB |
| 742d4b6 | 21.58 KiB | 546.20 KiB | 524.61 KiB |
Previous results on branch: philprime/fix-sr-options
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f6a2998 | 1225.73 ms | 1247.45 ms | 21.72 ms |
| ed3f5f1 | 1223.53 ms | 1241.73 ms | 18.20 ms |
| 78dae36 | 1235.55 ms | 1253.69 ms | 18.14 ms |
| 20e0a2f | 1232.69 ms | 1242.06 ms | 9.37 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f6a2998 | 23.76 KiB | 862.54 KiB | 838.78 KiB |
| ed3f5f1 | 23.76 KiB | 862.54 KiB | 838.78 KiB |
| 78dae36 | 23.76 KiB | 862.54 KiB | 838.78 KiB |
| 20e0a2f | 23.76 KiB | 861.54 KiB | 837.78 KiB |
There was a problem hiding this comment.
Is this change entirely motivated by the inconsistency in the default value being set for enableViewRendererV2? Personally, I find these changes confusing and potentially dangerous. We cannot rely on comments to enforce consistency in the business logic, those kinds of constraints need to be coded. Yes, you can catch them in unit tests, but this introduces almost 1,000 lines of test; that is also code that is prone to errors, requires its own maintenance, and slows down future changes. A lot of that checking can be done by the compiler if we keep the target code simpler. And we wouldn't need the hacks to avoid recursive convenience init calls.
My approach here would probably involve deduplicating magic values that are used as defaults in variable declarations and default parameter values into static variables or even into a structure called Defaults. One source of truth. Here's what that would look like: #5214. A lot of your tests might still provide value so I don't necessarily think you need to throw all that effort away.
It's unfortunate that this class was ever written with publicly available initializers and mutable properties, as this is the kind of mess it leads to. Better would have been to use a builder pattern instead of offering multiple types of initializers. We use that elsewhere so I'm not sure why we didn't here. Sorry you have to deal with that now 😭
|
Thanks for the feedback @armcknight, I already had a discussion with @philipphofmann yesterday, that this situation is quite complex and due the some of these initializers being public and already shipped to production made it even harder and frustrating to find a solution that covers all.
This is the second time that a default value was only partially updated and therefore not consistent, so it must be covered somehow. I agree with most of your statements, these options are just so badly designed that any change can cause public facing issues. IMHO some of the initializers should not have been public in the first place.
Yes, I had this one approach in my drafts as well but it had two additional downsides:
Yes, this is terrible to maintain, but it is what is now. I added a note for v9 |
|
I don't believe this code will be terrible to maintain, because we're not going to change that code often, as it's a public API. The tests can only change when the requirements change, which should only be the case in the next major release. As these APIs are a bit of a mess and we can't fix that now, let's agree on a somewhat OK solution and fix it later. |
There was a problem hiding this comment.
LGTM, we need so many tests because the logic is so complex. Without all these tests, we can't be sure everything works. We can reduce the number of tests to omit some of the parameters, but the rest is required, IMO. I included my view on your concerns in #5210 (comment), @armcknight.
Thanks for adding all the tests, @philprime
And yes, that's the root cause, @armcknight. We should fix this in V9. |
|
Based on your review feedback I refactored the initializers to use the default values in the new public type |
antonis
left a comment
There was a problem hiding this comment.
Thank you for all the changes @philprime 🙇
The changes on this PR LGTM and worked as expected with RN in my tests 🚀
philippsuess
left a comment
There was a problem hiding this comment.
LGTM, with a couple of suggestions. Thanks
|
Nice work getting this across the finish line @philprime! 🥇 |
#5210 isn't released yet.
#5210 hasn't been released yet.

📜 Description
This commit introduces several enhancements to the SentryReplayOptions class, including new properties for better configuration and handling of session replay options. Key changes include:
Covered cases:
💡 Motivation and Context
enableViewRendererV2was not enabled by default everywhere)💚 How did you test it?
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.