Repository navigation
feat(android): Add WebView tracing options with allowed hosts - #6516
Merged
Merged
Conversation
Add SentryWebViewTracing.addTracePropagation, which writes the current trace into pages from allowed hosts as sentry-trace and baggage meta tags before any page script runs, so @sentry/browser in the page continues the trace on pageload. It uses androidx.webkit's document-start script, a compileOnly dependency checked at runtime, and adds a sample screen and an instrumented test. Refs JAVA-716 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A WebView origin rule without a port only matches port 443, so a non-default port in an allowedHosts entry is now kept in the rule. androidx.webkit is compileOnly, so an app may ship an older version than the SDK was compiled against. A LinkageError is now caught, like for androidx.activity in the feedback form, and the call returns false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…call A call off the WebView's thread returns false without touching the WebView, which left Sentry's previous script installed. The removal is now posted to the WebView's thread, and skipped if a call on that thread replaced the script in the meantime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The off-thread cleanup compared against one counter shared by all WebViews, bumped before the replacement finished. A concurrent off-thread call could then remove a script that was just installed, and a call on another WebView cancelled this WebView's cleanup. The count is now kept per WebView, with weak keys, and bumped once the replacement is done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sample no longer shows an iframe; the instrumented test in sentry-uitest-android still checks that iframes don't get the trace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page's location.hostname is in punycode, so an allowedHosts entry like münchen.de never matched. Non-ASCII entries are now converted with IDN.toASCII, and entries that cannot be converted are dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oval Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opagation # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
📲 Install BuildsAndroid
|
7 of 9 tasks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markushi
approved these changes
Nov 10, 2026
…opagation-targets # Conflicts: # CHANGELOG.md # sentry-android-core/api/sentry-android-core.api # sentry-android-core/src/main/java/io/sentry/android/core/SentryWebViewTracing.java # sentry-android-core/src/test/java/io/sentry/android/core/SentryWebViewTracingTest.kt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
antonis
marked this pull request as ready for review
November 10, 2026 08:58
antonis
requested review from
0xadam-brown and
runningcode
and removed request for
a team
November 10, 2026 08:58
1 of 6 tasks
3 tasks done
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
Adds
options.webViewTracing.allowedHoststoSentryAndroidOptions, also settable with theio.sentry.webview-tracing.allowed-hostsmanifest entry, and aSentryWebViewTracing.addTracePropagation(webView)overload that uses it.The list is empty by default. With no hosts set, the overload logs a warning and returns
false. Passing hosts explicitly works as before.💡 Motivation and Context
#6395 (comment)
💚 How did you test it?
addTracePropagation(webView):📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps