Skip to content

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

Open
43jay wants to merge 1 commit 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 1 commit intomobile-935/ios-swift-appfrom
mobile-935/data-classes

Conversation

@43jay
Copy link
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

linear bot commented Mar 3, 2026

@github-actions
Copy link
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
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 e717c1a

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

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@cd8e4f0). 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.957%           
============================================================
  Files                               ?       486           
  Lines                               ?     28872           
  Branches                            ?     12546           
============================================================
  Hits                                ?     24529           
  Misses                              ?      4295           
  Partials                            ?        48           
Files with missing lines Coverage Δ
...tegrations/SessionReplay/SentryReplayOptions.swift 97.206% <ø> (ø)
...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 cd8e4f0...e717c1a. 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
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.

@43jay 43jay force-pushed the mobile-935/data-classes branch from 9a4f8b3 to c62d15c Compare March 6, 2026 16:33
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.
import Foundation

/// Warning codes for network body capture issues.
enum NetworkBodyWarning: String {
Copy link
Contributor

Choose a reason for hiding this comment

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

m: Are these strings defined anywhere?
If they, can you add a link to the doc for future references?

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.

2 participants