Skip to content

feat(network-details): Hook up request/response capture in SentryNetworkTracker#7588

Draft
43jay wants to merge 2 commits intomobile-935/extract-network-detailsfrom
mobile-935/hook-up-sentry-network-tracker
Draft

feat(network-details): Hook up request/response capture in SentryNetworkTracker#7588
43jay wants to merge 2 commits intomobile-935/extract-network-detailsfrom
mobile-935/hook-up-sentry-network-tracker

Conversation

@43jay
Copy link
Collaborator

@43jay 43jay commented Mar 4, 2026

📜 Description

Hook the network details implementation into SentryNetworkTracker by implementing the 2 entrypoints

[SentryNetworkTracker captureRequestDetails:networkCaptureBodies:networkRequestHeaders:]
[SentryNetworkTracker captureResponseDetails:response:request:task:]

💡 Motivation and Context

This PR updates SentryNetworkTracker to call into extraction logic introduced in previous PRs.

💚 How did you test it?

See other PRs for tests.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled. requires SDKOptions config (networkDetailAllowUrls)
  • I updated the docs if needed. future PR
  • I updated the wizard if needed. n/a
  • Review from the native team if needed. n/a
  • No breaking change or entry added to the changelog. future PR #skip-changelog
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Closes #7589

@linear
Copy link

linear bot commented Mar 4, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

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

Generated by 🚫 dangerJS against 624e1f5

@43jay 43jay changed the title feat(network-details): Hook up request and response capture in SentryNetworkTracker feat(network-details): Hook up request/response capture in SentryNetworkTracker Mar 4, 2026
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 20.00000% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.864%. Comparing base (6e5c5bb) to head (624e1f5).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
Sources/Sentry/SentryNetworkTracker.m 14.754% 52 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                           Coverage Diff                            @@
##           mobile-935/extract-network-details     #7588       +/-   ##
========================================================================
- Coverage                              85.009%   84.864%   -0.145%     
========================================================================
  Files                                     486       486               
  Lines                                   28965     29025       +60     
  Branches                                12610     12620       +10     
========================================================================
+ Hits                                    24623     24632        +9     
- Misses                                   4293      4344       +51     
  Partials                                   49        49               
Files with missing lines Coverage Δ
...ons/SessionReplay/SentryReplayNetworkDetails.swift 95.327% <100.000%> (ø)
Sources/Sentry/SentryNetworkTracker.m 84.770% <14.754%> (-14.882%) ⬇️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e5c5bb...624e1f5. Read the comment docs.

@43jay 43jay force-pushed the mobile-935/hook-up-sentry-network-tracker branch from 5f57b05 to a4f221a Compare March 4, 2026 21:03
@43jay 43jay force-pushed the mobile-935/extract-network-details branch from 0d2b4c1 to 3547546 Compare March 4, 2026 21:03
@43jay 43jay force-pushed the mobile-935/hook-up-sentry-network-tracker branch from a4f221a to fde4a5e Compare March 4, 2026 22:00
@43jay 43jay force-pushed the mobile-935/extract-network-details branch from 3547546 to e7c5abb Compare March 4, 2026 22:00
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

[self captureRequestDetails:sessionTask
networkCaptureBodies:options.sessionReplay.networkCaptureBodies
networkRequestHeaders:options.sessionReplay.networkRequestHeaders];
}
Copy link

Choose a reason for hiding this comment

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

Request details captured before bytes are sent

Medium Severity

captureRequestDetails is called in urlSessionTask:setState: for every state transition, and its associated-object guard ensures only the first call takes effect. Since the setState: swizzle runs before the original, the first invocation occurs on the Running transition when countOfBytesSent is still 0. The countOfBytesSent > 0 branch is effectively dead code — request size always falls back to bodyData.length, which is often nil for stream-based uploads.

Additional Locations (1)

Fix in Cursor Fix in Web

@43jay 43jay force-pushed the mobile-935/hook-up-sentry-network-tracker branch from fde4a5e to 8b6853c Compare March 6, 2026 16:33
@43jay 43jay force-pushed the mobile-935/extract-network-details branch from e7c5abb to 2e9607e Compare March 6, 2026 16:33
@43jay 43jay marked this pull request as draft March 6, 2026 18:44
@43jay 43jay force-pushed the mobile-935/extract-network-details branch from 2e9607e to 6e5c5bb Compare March 6, 2026 19:25
@43jay 43jay force-pushed the mobile-935/hook-up-sentry-network-tracker branch from 8b6853c to 624e1f5 Compare March 6, 2026 19:25
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

🚨 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:

  • Sources/Sentry/SentryNetworkTracker.m

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant