feat(network-details): New swizzling to capture response bodies for session replay#7584
feat(network-details): New swizzling to capture response bodies for session replay#7584
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7584 +/- ##
=============================================
- Coverage 85.330% 85.172% -0.158%
=============================================
Files 490 490
Lines 29448 29500 +52
Branches 12738 12755 +17
=============================================
- Hits 25128 25126 -2
- Misses 4269 4322 +53
- Partials 51 52 +1
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
82a2dd5 to
9473efb
Compare
philipphofmann
left a comment
There was a problem hiding this comment.
Thanks for tackling this. I have one major high-level question before reviewing this more closely.
71fd40b to
78d1d60
Compare
9473efb to
5bc5830
Compare
78d1d60 to
9a4f8b3
Compare
5bc5830 to
7faf4ef
Compare
9a4f8b3 to
c62d15c
Compare
7faf4ef to
6e19c0a
Compare
c62d15c to
e717c1a
Compare
6e19c0a to
9a8d48d
Compare
8584657 to
c3afd6d
Compare
bc47f47 to
7167c11
Compare
4e16c52 to
ef11583
Compare
7167c11 to
72aa000
Compare
ef11583 to
4a96fe9
Compare
72aa000 to
040e097
Compare
…onse capture Add (no-op) callback into SentryNetworkTracker Remove run-time discovery for swizzle targets; directly swizzle [NSURLSession class] Add unit test to do run-time discovery and report if assumptions invalid
#7584 (comment) test_dataTaskWithURL_doesNotCallThrough_dataTaskWithRequest test_dataTaskWithRequest_doesNotCallThrough_dataTaskWithURL were asserting that one impl does not rely on the other internally. There's no reason to believe that they do - the test was probably checking for something that would not happen. Additionally it was relying on method_setImplementation which could cause random failures in CI if not cleaned up properly => remove
…etworkDetailHasUrls
06583c1 to
22e2b20
Compare
|
moved failing test to PR with implementation (#7590) |
📲 Install BuildsiOS
|
DebugWithoutUIKit build was failing, now it passes \0/
|
added missing && ! SENTRY_NO_UI_FRAMEWORK in SentryNetworkTrackingIntegration.swift |
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| df67624 | 1225.12 ms | 1259.90 ms | 34.78 ms |
| 787537a | 1218.35 ms | 1251.72 ms | 33.38 ms |
| b6fa517 | 1218.83 ms | 1257.47 ms | 38.63 ms |
| ffb6adc | 1218.60 ms | 1247.47 ms | 28.87 ms |
| 1c5ecda | 1219.35 ms | 1253.76 ms | 34.41 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| df67624 | 24.14 KiB | 1.14 MiB | 1.12 MiB |
| 787537a | 24.14 KiB | 1.15 MiB | 1.12 MiB |
| b6fa517 | 24.14 KiB | 1.14 MiB | 1.12 MiB |
| ffb6adc | 24.14 KiB | 1.15 MiB | 1.12 MiB |
| 1c5ecda | 24.14 KiB | 1.15 MiB | 1.12 MiB |
|
missed make format on a file |
|
missed a |
Run make generate-public-api
🚨 Detected changes in high risk code 🚨High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:
|
📜 Description
Newly swizzled methods:
[NSURLSession dataTaskWithURL:completionHandler:][NSURLSession dataTaskWithRequest:completionHandler:]This swizzling is skipped when network detail capture is not enabled (SentryReplayOptions#networkDetailAllowUrls is empty)
Added testing to validate for future iOS SDKs that the
IMPs we are swizzling are implemented directly on NSURLSession: SentryNSURLSessionTaskSearchTeststest_URLSessionDataTaskWithRequest_ByIosVersiontest_URLSessionDataTaskWithURL_ByIosVersion💡 Motivation and Context
With this change sentry-cocoa can inspect response bodies of NSURLSession
dataTask's that use completionHandlers.Swizzling is added to inspect the NSURLResponse before delegating to the original completionHandler.
The request body will be captured via existing swizzling into SentryNetworkTracker (
setState,resume).See swizzling discussion on #7582 for more context.
💚 How did you test it?
Unit tests
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled. gated by networkDetailAllowUrls