Skip to content

feat(network-details): Introduce data classes for extracting network details to session replay#7582

Open
43jay wants to merge 3 commits intomobile-935/ios-swift-appfrom
mobile-935/data-classes
Open

feat(network-details): Introduce data classes for extracting network details to session replay#7582
43jay wants to merge 3 commits intomobile-935/ios-swift-appfrom
mobile-935/data-classes

Conversation

@43jay
Copy link
Copy Markdown
Collaborator

@43jay 43jay commented Mar 3, 2026

📜 Description

Class diagram

SentryReplayNetworkDetails.swift     (@objc, @_spi(Private) public)
├── method: String?
├── statusCode: NSNumber?
├── requestBodySize: NSNumber?       (computed from request.size)
├── responseBodySize: NSNumber?      (computed from response.size)
├── request: Detail?
├── response: Detail?
│
├── Detail                           (Swift-only struct)
│   ├── size: NSNumber?
│   ├── body: Body?
│   └── headers: [String: String]
│
├── Body                             (Swift-only struct)
│   ├── content: BodyContent
│   └── warnings: [NetworkBodyWarning]
│
├── BodyContent                      (Swift-only enum)
│   ├── .json(Any)                   — parsed dict/array
│   └── .text(String)                — plain text or placeholder
│
└── NetworkBodyWarning               (Swift-only enum)
    ├── .jsonTruncated
    ├── .textTruncated
    ├── .invalidJson
    └── .bodyParseError

Expected usage

SentryNetworkTracker.m (ObjC — producer)
  │
  │  let details = SentryReplayNetworkDetails(method: "POST")
  │  [details setRequestWithSize:… body:… headers:…]
  │  [details setResponseWithStatusCode:… size:… body:… headers:…]
  │  breadcrumbData["_networkDetails"] = details
  │
  ▼
SentrySRDefaultBreadcrumbConverter.swift (Swift — consumer)
  │
  │  let details = breadcrumb.data["_networkDetails"] as? SentryReplayNetworkDetails
  │  let serialized = details.serialize()
  │  // → { method, statusCode, requestBodySize, responseBodySize,
  │  //     request: { size, headers, body: { body, warnings } },
  │  //     response: { size, headers, body: { body, warnings } } }
  │
  ▼
  RRWebSpanEvent data payload

💡 Motivation and Context

See corresponding class definitions in sentry-java

This PR only defines the data contract used by PRs higher in the stack.

See first PR for more motivation/context.

💚 How did you test it?

Unit tests are in the next PR in the stack, which introduces the body parsing and header extraction logic that operates on these types.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes. See future PRs where impl is added
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled. requires opt-in via specifying 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. #skip-changelog future PR
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs. internal classes

Closes #7623

@linear
Copy link
Copy Markdown

linear bot commented Mar 3, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 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
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

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

Generated by 🚫 dangerJS against 41f8885

@43jay 43jay marked this pull request as ready for review March 3, 2026 19:51
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 0% with 53 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (mobile-935/ios-swift-app@1865d4a). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ons/SessionReplay/SentryReplayNetworkDetails.swift 0.000% 53 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                     Coverage Diff                      @@
##             mobile-935/ios-swift-app     #7582   +/-   ##
============================================================
  Coverage                            ?   84.985%           
============================================================
  Files                               ?       486           
  Lines                               ?     28906           
  Branches                            ?     12577           
============================================================
  Hits                                ?     24566           
  Misses                              ?      4293           
  Partials                            ?        47           
Files with missing lines Coverage Δ
...tegrations/SessionReplay/SentryReplayOptions.swift 97.175% <ø> (ø)
...ons/SessionReplay/SentryReplayNetworkDetails.swift 0.000% <0.000%> (ø)

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 1865d4a...41f8885. Read the comment docs.

@43jay 43jay force-pushed the mobile-935/data-classes branch from 71fd40b to 78d1d60 Compare March 4, 2026 21:03
@43jay 43jay force-pushed the mobile-935/ios-swift-app branch from 0898913 to 240ba73 Compare March 4, 2026 21:03
@43jay 43jay force-pushed the mobile-935/data-classes branch from 78d1d60 to 9a4f8b3 Compare March 4, 2026 22:00
@43jay 43jay force-pushed the mobile-935/data-classes branch from e717c1a to 2d31c8d Compare March 9, 2026 19:02
@43jay 43jay force-pushed the mobile-935/ios-swift-app branch from cd8e4f0 to 327fd2e Compare March 9, 2026 19:02
Copy link
Copy Markdown

@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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Empty headers always serialized unlike empty warnings
    • Updated Detail.serialize() to only include headers when the dictionary is non-empty, matching the existing empty-collection serialization behavior.

Create PR

Or push these changes by commenting:

@cursor push aa8c3f54db
Preview (aa8c3f54db)
diff --git a/Sources/Swift/Integrations/SessionReplay/SentryReplayNetworkDetails.swift b/Sources/Swift/Integrations/SessionReplay/SentryReplayNetworkDetails.swift
--- a/Sources/Swift/Integrations/SessionReplay/SentryReplayNetworkDetails.swift
+++ b/Sources/Swift/Integrations/SessionReplay/SentryReplayNetworkDetails.swift
@@ -71,7 +71,9 @@
             var result = [String: Any]()
             if let size { result["size"] = size }
             if let body { result["body"] = body.serialize() }
-            result["headers"] = headers
+            if !headers.isEmpty {
+                result["headers"] = headers
+            }
             return result
         }
     }
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@43jay 43jay force-pushed the mobile-935/ios-swift-app branch from 327fd2e to faac0a4 Compare March 9, 2026 19:48
@43jay 43jay force-pushed the mobile-935/data-classes branch 2 times, most recently from 72a427a to 56c7a59 Compare March 9, 2026 20:51
Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Please add the link mentioned by @itaybre in the PR comments, then LGTM

@philprime philprime added the ready-to-merge Use this label to trigger all PR workflows label Mar 10, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Mar 10, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
App io.sentry.sample.SDK-Size 9.6.0 (1) Release Install Build

@43jay 43jay force-pushed the mobile-935/data-classes branch from 56c7a59 to a41d68f Compare March 10, 2026 21:06
@43jay 43jay force-pushed the mobile-935/ios-swift-app branch from 8a5da47 to 719553e Compare March 10, 2026 21:06
@sentry
Copy link
Copy Markdown

sentry bot commented Mar 10, 2026

Sentry Build Distribution

App Version Configuration
App 9.6.0 (1) Release

@43jay
Copy link
Copy Markdown
Collaborator Author

43jay commented Mar 11, 2026

Please add the link mentioned by @itaybre in the PR comments, then LGTM

Done

43jay added 3 commits March 16, 2026 14:41
Add SentryReplayNetworkDetails — a single Swift class that encapsulates
network request/response data for session replay breadcrumbs.

Exposes minimal @objc surface (init, setRequest, setResponse) for ObjC
callers (SentryNetworkTracker), with idiomatic Swift internals: nested
Body, Detail, and BodyContent types, plus a NetworkBodyWarning enum.
@43jay 43jay force-pushed the mobile-935/data-classes branch from a41d68f to 41f8885 Compare March 16, 2026 20:31
@43jay 43jay force-pushed the mobile-935/ios-swift-app branch from 719553e to 1865d4a Compare March 16, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants