Skip to content

RUM-16634: Add wildcard host pattern matching to WebViewTracking#3540

Merged
kikoveiga merged 2 commits into
developfrom
kikoveiga/rum-16634/webview-host-patterns
Jul 1, 2026
Merged

RUM-16634: Add wildcard host pattern matching to WebViewTracking#3540
kikoveiga merged 2 commits into
developfrom
kikoveiga/rum-16634/webview-host-patterns

Conversation

@kikoveiga

@kikoveiga kikoveiga commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Extends the existing WebViewTracking.enable API so that allowedHosts entries may be wildcard host patterns (e.g., "*.example.com, "preview-*.shopist.io") in addition to plain hosts. Patterns are validated on our side and then transmitted to the Browser SDK through the getAllowedWebViewHosts() bridge.
  • Adds a HostPatternSanitizer to dd-sdk-android-core which handles validating and normalizing wildcard patterns. It lives in the core so the incoming first-party-hosts wildcard matching work can reuse it.

Motivation

Customers weren't able to easily enumerate hostnames loaded in a WebView such as ephemeral preview URLs, multi-tenant subdomains.

Additional Notes

iOS PR: DataDog/dd-sdk-ios#2963
Broswer PR: DataDog/browser-sdk#4703

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@kikoveiga
kikoveiga requested review from a team as code owners June 12, 2026 16:15
@datadog-datadog-prod-us1-2

This comment has been minimized.

@kikoveiga
kikoveiga marked this pull request as draft June 12, 2026 16:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3030c6a1ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov-commenter

codecov-commenter commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.77%. Comparing base (9e60d05) to head (a43c1a3).
⚠️ Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...android/core/configuration/HostPatternSanitizer.kt 96.67% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3540      +/-   ##
===========================================
- Coverage    72.80%   72.77%   -0.03%     
===========================================
  Files          974      975       +1     
  Lines        35228    35268      +40     
  Branches      5965     5974       +9     
===========================================
+ Hits         25645    25663      +18     
- Misses        7915     7929      +14     
- Partials      1668     1676       +8     
Files with missing lines Coverage Δ
...lin/com/datadog/android/webview/WebViewTracking.kt 85.04% <100.00%> (+0.61%) ⬆️
...dog/android/webview/internal/DatadogEventBridge.kt 100.00% <100.00%> (ø)
...android/core/configuration/HostPatternSanitizer.kt 96.67% <96.67%> (ø)

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kikoveiga
kikoveiga force-pushed the kikoveiga/rum-16634/webview-host-patterns branch 3 times, most recently from 363dc08 to ec19467 Compare June 15, 2026 16:34
@kikoveiga
kikoveiga force-pushed the kikoveiga/rum-16634/webview-host-patterns branch 8 times, most recently from 8300e91 to 4a8878d Compare June 24, 2026 11:41
@kikoveiga
kikoveiga requested a review from Copilot June 24, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the WebView tracking configuration to support wildcard host patterns (e.g. *.example.com, preview-*.shopist.io) and validates/normalizes these patterns before passing them to the Browser SDK via the JS bridge. Introduces a reusable HostPatternValidator in dd-sdk-android-core to centralize wildcard-pattern validation logic.

Changes:

  • Add HostPatternValidator (core) + unit tests, and update core API surface files accordingly.
  • Update DatadogEventBridge.getAllowedWebViewHosts() to sanitize plain hosts and validate wildcard patterns separately.
  • Add/adjust WebView module unit tests and detekt safe-call allowlist entries needed by the new implementation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
features/dd-sdk-android-webview/src/test/kotlin/com/datadog/android/webview/WebViewTrackingTest.kt Adds coverage ensuring wildcard patterns are passed through the bridge correctly.
features/dd-sdk-android-webview/src/test/kotlin/com/datadog/android/webview/internal/DatadogEventBridgeTest.kt Adds coverage for mixed plain hosts + wildcard patterns, invalid patterns, and edge cases.
features/dd-sdk-android-webview/src/main/kotlin/com/datadog/android/webview/WebViewTracking.kt Updates public API KDoc and wires an InternalLogger into the bridge.
features/dd-sdk-android-webview/src/main/kotlin/com/datadog/android/webview/internal/DatadogEventBridge.kt Implements wildcard-vs-plain host splitting and validation prior to JSON serialization.
detekt_custom_safe_calls.yml Allows new Kotlin/OkHttp calls used by the validator/bridge.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/configuration/HostPatternValidatorTest.kt Adds unit tests for wildcard validation rules and logging behavior.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/configuration/HostPatternValidator.kt Introduces reusable wildcard host-pattern validation/normalization.
dd-sdk-android-core/api/dd-sdk-android-core.api Updates API dump to include HostPatternValidator.
dd-sdk-android-core/api/apiSurface Updates API surface snapshot to include HostPatternValidator.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kikoveiga
kikoveiga force-pushed the kikoveiga/rum-16634/webview-host-patterns branch from 4a8878d to 37d0497 Compare June 24, 2026 12:27
@kikoveiga
kikoveiga marked this pull request as ready for review June 24, 2026 13:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37d0497a16

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sbarrio
sbarrio requested a review from satween June 25, 2026 07:25
@kikoveiga
kikoveiga force-pushed the kikoveiga/rum-16634/webview-host-patterns branch from 37d0497 to 47ee896 Compare June 26, 2026 13:03
satween
satween previously approved these changes Jun 30, 2026

@satween satween left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good except question http -> htts transformation 👍

@kikoveiga
kikoveiga force-pushed the kikoveiga/rum-16634/webview-host-patterns branch from d91107c to a43c1a3 Compare June 30, 2026 17:46
@kikoveiga
kikoveiga requested a review from satween June 30, 2026 17:47
@kikoveiga
kikoveiga merged commit 3533bee into develop Jul 1, 2026
27 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/rum-16634/webview-host-patterns branch July 1, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants