Repository navigation
feat: Add SentryObjC WebView trace propagation - #9488
Merged
Merged
Conversation
Add SentryWebViewTracing.addTracePropagation(to:options:), which injects the current trace as sentry-trace and baggage meta tags into pages on allowed hosts before page scripts run, so @sentry/browser continues the trace on pageload. It accepts a WKUserContentController, WKWebViewConfiguration, WKWebView, or SwiftUI WebPage.Configuration (iOS 26+). SentryObjC exposes it as SentryObjCWebViewTracing. The injected script and host normalization match sentry-react-native and sentry-java. Using the API records the WebViewTracePropagation integration for adoption. Extract the outgoing trace lookup from the network tracker into SentryOutgoingTrace so both paths share it.
Run @sentry/browser in the iOS-Swift WebView screen so its pageload continues the app's trace, and add a SwiftUI WebPage screen on iOS 26. UI tests check that both pages see the injected trace before their own scripts run. Add a test that loads a page in a real WebPage created from a configuration with Sentry's script.
Move the lookup of the trace propagated to outgoing requests from SentryNetworkTracker into SentryOutgoingTrace: the span bound to the scope if it belongs to a tracer, otherwise the scope's propagation context. Behavior is unchanged. This lets WebView trace propagation reuse the same lookup.
Move SentryObjCWebViewTracing, its tests, and the SentryObjC API snapshots to a separate pull request stacked on this one, to keep this one focused on the Swift API.
Expose SentryWebViewTracing through the SentryObjC SDK as SentryObjCWebViewTracing and SentryObjCWebViewTracingOptions, with overloads for WKUserContentController, WKWebViewConfiguration, and WKWebView. Calls off the main thread return NO.
7 of 8 tasks
Contributor
|
📲 Install BuildsiOS
|
Size Analysis1 component analyzed iOS Builds
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7d10643. Configure here.
antonis
marked this pull request as ready for review
October 29, 2026 13:01
antonis
requested review from
0xadam-brown,
alwx,
itaybre,
philprime and
runningcode
and removed request for
a team
October 29, 2026 13:01
Resolve the current hub once in addTracePropagation and pass it to both the adoption marker and the script install, and replace the test Hub double with real hubs. Keep SentrySDKWrapper.dsn internal: the sample pages read the DSN from SentrySDK.startOption instead. Merge the changelog entry into the existing Features section of Unreleased.
…-propagation-objc
1 of 6 tasks
The SwiftPM package tests run on the iOS Simulator without a host app. There, WebKit's web content process intermittently becomes unresponsive, so the two WebView page-load tests time out. The Xcode unit test plans and the iOS-Swift UI tests keep covering real page loads.
…-propagation-objc
antonis
added a commit
to getsentry/sentry-docs
that referenced
this pull request
Nov 5, 2026
<!-- Keep the urgency section so automation can prioritize this PR. You may delete other sections you don't need. --> ## DESCRIBE YOUR PR Updates the Apple WebView page for the new trace connection in the Cocoa SDK. It replaces the statement that the SDK doesn't interact with web views with setup for `SentryWebViewTracing.addTracePropagation`, which writes the app's trace into `WKWebView` pages as `sentry-trace` and `baggage` meta tags before page scripts run, so `@sentry/browser` continues it on pageload. - Swift and SentryObjC examples, plus a SwiftUI `WebPage` section (iOS, macOS, visionOS 26+) - `allowedHosts` matching and the trust warning, aligned with the [React Native WebView page](https://docs.sentry.io/platforms/react-native/configuration/webview/) - The snapshot behavior, supported platforms, and limitations Resolves getsentry/sentry-cocoa#9136 >⚠️ SDK changes: getsentry/sentry-cocoa#9474 (Swift API) and getsentry/sentry-cocoa#9488 (SentryObjC API). The version alert says `9.33.0`; it will be updated if the release differs. Keep this as a draft until those PRs ship. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the due date. You can update this information later by editing the PR description. - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've supplied a deadline. Thanks in advance for your help! ## PRE-MERGE CHECKLIST _Make sure you've checked the following before merging your changes:_ - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Exposes WebView trace propagation through the SentryObjC SDK.
SentryObjCWebViewTracingOptions *options = [[SentryObjCWebViewTracingOptions alloc] initWithAllowedHosts:@[ @"app.example.com" ]]; [SentryObjCWebViewTracing addTracePropagationToWebView:webView options:options];SentryObjCWebViewTracinghas overloads forWKUserContentController,WKWebViewConfiguration, andWKWebView, and forwards toSentryWebViewTracing. The SwiftUIWebPageoverload is Swift-only.YESif the script was added. Called off the main thread, it returnsNOinstead of trapping.💡 Motivation and Context
Split out of #9474 to keep it focused on the Swift API. Public APIs need to be exposed through
SentryObjCbefore release.💚 How did you test it?
SentryObjCWebViewTracingTestsfor each overload, repeated calls, a closed SDK, and calls off the main threadSentryObjCfor iOS and ran the tests on macOS📝 Checklist
sendDefaultPIIis enabled.