Repository navigation
Commit 50ebe9e
feat(android): Add WebView tracing options with allowed hosts (#6516)
* feat(android): Connect traces with web content in a WebView
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>
* changelog
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(android): Keep non-default ports and handle old androidx.webkit
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>
* fix(android): Remove the previous WebView script after an off-thread 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>
* fix(android): Track WebView script replacements per WebView
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>
* ref(samples): Move the WebView trace screen to the Tracing tab
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>
* fix(android): Match internationalized hosts in WebView trace propagation
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>
* docs(changelog): Shorten WebView trace propagation entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(android): Never throw from the posted WebView script removal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(android): Rethrow fatal errors from the posted WebView script removal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add docs link to the changelog
* Updated link to WebView documentation in CHANGELOG.
* feat(android): Use tracePropagationTargets as the default WebView hosts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(android): Add WebView tracing options with allowed hosts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ref(android): Default WebView allowed hosts to an empty list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 144b2ee commit 50ebe9e
9 files changed
Lines changed: 162 additions & 0 deletions
File tree
- sentry-android-core
- api
- src
- main/java/io/sentry/android/core
- test/java/io/sentry/android/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| 444 | + | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
| |||
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
| 633 | + | |
632 | 634 | | |
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
636 | 644 | | |
637 | 645 | | |
638 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
545 | 547 | | |
546 | 548 | | |
547 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
548 | 556 | | |
549 | 557 | | |
550 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
324 | 328 | | |
325 | 329 | | |
326 | 330 | | |
| |||
950 | 954 | | |
951 | 955 | | |
952 | 956 | | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
953 | 966 | | |
954 | 967 | | |
955 | 968 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
52 | 72 | | |
53 | 73 | | |
54 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1211 | 1211 | | |
1212 | 1212 | | |
1213 | 1213 | | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1214 | 1240 | | |
1215 | 1241 | | |
1216 | 1242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
258 | 270 | | |
259 | 271 | | |
260 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
367 | 369 | | |
368 | 370 | | |
369 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
370 | 410 | | |
371 | 411 | | |
372 | 412 | | |
| |||
0 commit comments