Skip to content

feat(data-collection): Gate session replay network body collection - #8547

Open
philprime wants to merge 2 commits into
philprime/network-tracker-conversionfrom
feat/replay-data-collection-bodies
Open

feat(data-collection): Gate session replay network body collection#8547
philprime wants to merge 2 commits into
philprime/network-tracker-conversionfrom
feat/replay-data-collection-bodies

Conversation

@philprime

@philprime philprime commented Jul 24, 2026

Copy link
Copy Markdown
Member

📜 Description

Wire Session Replay network body capture to options.dataCollection.httpBodies on top of the Swift SentryNetworkTracker conversion in #8502.

Replay requests resolve as outgoingRequest bodies and responses resolve as incomingResponse bodies. The Replay integration can override the global setting through the new SentryReplayOptions.NetworkBodyCapture values:

  • .inherit follows dataCollection.httpBodies for each direction and is the default
  • .enabled captures both Replay request and response bodies
  • .disabled captures neither

Parseable JSON objects and form-urlencoded bodies apply the canonical sensitive denylist to top-level keys. Filtering is intentionally non-recursive. JSON values without a top-level key-value structure, malformed bodies, text, HTML, XML, binary data, and unknown content types are replaced with [Filtered].

The hybrid SDK dictionary option continues accepting Boolean values, mapping true to .enabled, false to .disabled, and an omitted value to .inherit. The RRWeb options event serializes the three states as inherit, enabled, or disabled.

💡 Motivation and Context

The data collection specification makes dataCollection the default source of truth while allowing integration-level overrides to take precedence. It also requires automatically captured raw bodies that cannot be parsed into key-value data to be replaced with [Filtered].

This is a stacked PR based on philprime/network-tracker-conversion because the request and response capture decisions belong in the Swift SentryNetworkTracker.

Fixes #8250

💚 How did you test it?

  • make test-ios-v10 FOR_AGENTS=true ONLY_TESTING=SentryTests/SentryReplayOptionsTests,SentryTests/SentryReplayNetworkDetailsBodyTests,SentryTests/SentryNetworkTrackerTests
  • make test-ios FOR_AGENTS=true ONLY_TESTING=SentryTests/SentryReplayOptionsTests,SentryTests/SentryReplayNetworkDetailsBodyTests,SentryTests/SentryNetworkTrackerTests
  • make test-macos-v10 FOR_AGENTS=true TEST_SCHEME=SentryObjCTests ONLY_TESTING=SentryObjCTests/SentryObjCReplayOptionsTests,SentryObjCCompatTests/SentryObjCCompatEnumConversionTests
  • make analyze
  • make build-ios-v10 FOR_AGENTS=true
  • make generate-public-api
  • make build-xcframework-sentryobjc-static SDKS=iphoneos
  • make build-xcframework-sentryobjc-dynamic SDKS=iphoneos

📝 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.
  • I updated the docs if needed.
  • I updated the wizard if needed. Not needed for this change.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs. Dictionary configuration remains Boolean-compatible.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

#skip-changelog

Resolve Session Replay request and response body capture from dataCollection.httpBodies unless Replay explicitly overrides it. Scrub sensitive top-level JSON and form values, and filter raw bodies that cannot be parsed safely.

Change the v10 Replay body capture option to a three-state enum so inheritance is explicit.

Fixes #8250
@github-actions

Copy link
Copy Markdown
Contributor

🚨 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/Swift/Networking/SentryNetworkTracker.swift

@github-actions

github-actions Bot commented Jul 24, 2026

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

Generated by 🚫 dangerJS against 7e6c233

@philprime philprime added ready-to-merge Use this label to trigger all PR workflows run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request labels Jul 24, 2026
@philprime
philprime marked this pull request as ready for review July 24, 2026 07:48
@sentry

sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.23.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1221.13 ms 1243.72 ms 22.60 ms
Size 24.14 KiB 1.26 MiB 1.23 MiB

Baseline results on branch: philprime/network-tracker-conversion

Startup times

Revision Plain With Sentry Diff
a91cc39 1224.22 ms 1256.36 ms 32.14 ms
602ee98 1213.90 ms 1245.86 ms 31.96 ms
602ee98 1236.15 ms 1265.19 ms 29.04 ms

App size

Revision Plain With Sentry Diff
a91cc39 24.14 KiB 1.26 MiB 1.24 MiB
602ee98 24.14 KiB 1.26 MiB 1.23 MiB
602ee98 24.14 KiB 1.26 MiB 1.23 MiB

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 run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request skip-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants