feat(network-details): Extract network details data to Session Replay#7590
feat(network-details): Extract network details data to Session Replay#759043jay wants to merge 5 commits intomobile-935/hook-up-sentry-network-trackerfrom
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 @@
## mobile-935/hook-up-sentry-network-tracker #7590 +/- ##
===============================================================================
+ Coverage 84.881% 84.895% +0.014%
===============================================================================
Files 486 486
Lines 29116 29170 +54
Branches 12639 12673 +34
===============================================================================
+ Hits 24714 24764 +50
- Misses 4354 4357 +3
- Partials 48 49 +1
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Sources/Swift/Integrations/SessionReplay/SentrySRDefaultBreadcrumbConverter.swift
Show resolved
Hide resolved
5f57b05 to
a4f221a
Compare
7cda42c to
c8da718
Compare
a4f221a to
fde4a5e
Compare
c8da718 to
e9fcc6c
Compare
fde4a5e to
8b6853c
Compare
e9fcc6c to
46f7481
Compare
46f7481 to
f35da26
Compare
8b6853c to
624e1f5
Compare
f35da26 to
f4312a8
Compare
d80d538 to
d08a33e
Compare
f4312a8 to
af0159e
Compare
d08a33e to
d5a8320
Compare
af0159e to
3852520
Compare
d5a8320 to
80df62b
Compare
3852520 to
58aafe3
Compare
3d0176a to
99f38e3
Compare
fea8910 to
05a57ee
Compare
99f38e3 to
bdadd3e
Compare
| }) | ||
|
|
||
| // Add Network Details data when available | ||
| if let networkRequestData = breadcrumb.data?["_networkDetails"] as? [String: Any] { |
There was a problem hiding this comment.
h: Please add unit tests for this serialization
There was a problem hiding this comment.
I have SentryNetworkDetailsData:serialize tests here
Tests/SentryTests/Networking/SentryReplayNetworkDetailsIntegrationTests.swift
introduced on #7585
| // Add network details if available for session replay | ||
| SentryReplayNetworkDetails *networkDetails | ||
| = objc_getAssociatedObject(sessionTask, &SentryNetworkDetailsKey); | ||
| if (networkDetails) { |
There was a problem hiding this comment.
h: Please add unit test for this case
There was a problem hiding this comment.
can you elaborate on what needs testing here?
05a57ee to
e15e24c
Compare
030d2e4 to
f986bfa
Compare
e15e24c to
c84ff73
Compare
f986bfa to
1fc4171
Compare
Sources/Swift/Integrations/SessionReplay/SentrySRDefaultBreadcrumbConverter.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Sources/Swift/Integrations/SessionReplay/SentrySRDefaultBreadcrumbConverter.swift
Outdated
Show resolved
Hide resolved
d43fd3c to
efa243d
Compare
c84ff73 to
5ea8b46
Compare
efa243d to
8079837
Compare
a741581 to
a925d4a
Compare
22fcb76 to
bb3966d
Compare
a925d4a to
44d3c4a
Compare
…Event Add populated NetworkRequestData to breadcrumb data SentryNetworkTracker#addBreadcrumbForSessionTask Read NetworkRequestData from breadcrumb when converting for session replay SentrySRDefaultBreadcrumbConverter
… breadcrumb #7588 (comment) in testing, the completionHandler is invoked after setState(.completed) returns. However based on research this is not guaranteed so lock so ensure no concurrent access to obj_get|setAssociatedState
RRWebOptionsEvent payload shows up in the `tags` panel on a session replay. networkDetailHasUrls is required to light-up the UI.
bb3966d to
dd6c72f
Compare
🚨 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:
|
|
|
||
| private func addNetworkDetails(from networkData: [String: Any], to data: inout [String: Any]) { | ||
| // Add top-level network metadata | ||
| if let method = networkData["method"] as? String { |
There was a problem hiding this comment.
h: Are network details without a method even accepted? Are all envelopes valid if just a statusCode or just a responseBodySize etc. is set? If yes, please add test cases where only individual values are available, so we can make sure that this behaviour is locked down

📜 Description
Upload network details data (
SentryNetworkRequestData) extracted by SentryNetworkTracker to the session replay backend.SentryNetworkRequestDataStored on the NSURLSessionTask while waiting for data (see previous prs)
SentryNetworkRequestData *networkRequestData = objc_setAssociatedObject(sessionTask, &SentryNetworkRequestDataKey);Stored in the Breadcrumb data after task has completed (
addBreadcrumbForSessionTask) (THIS PR)Extracted from Breadcrumb into RRWebEvent (
SentrySRDefaultBreadcrumbConverter) (THIS PR)💡 Motivation and Context
Last leg of data upload; now data is visible in replay dash.
💚 How did you test it?
Manual Testing with iOS-Swift test app
Navigate to Extras > Network Details
Initiate different types of request
Navigate to sentry.io test project and confirm session replay 'Network' tab shows requests with correct body and headers.
https://sentry-sdks.sentry.io/explore/replays/f5cff413ffd94561819...
Unit tests
Summary:
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled. gated by SentryReplayOptions#networkDetailAllowUrlsCloses #7591