Skip to content

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

@github-actions

Description

@github-actions

Note

The pull request "feat(network-details): Introduce data classes for extracting network details to session replay" was created by @43jay but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

📜 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

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions