Skip to content

[RUM-16633] Add wildcard host pattern matching to WebView tracking#2963

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
developfrom
bplasovska/RUM-15826/webview-wildcard-matching
Jun 9, 2026
Merged

[RUM-16633] Add wildcard host pattern matching to WebView tracking#2963
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
developfrom
bplasovska/RUM-15826/webview-wildcard-matching

Conversation

@barboraplasovska

@barboraplasovska barboraplasovska commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What and why?

Adds a new WebViewTracking.enable(webView:hostPatterns:[String]) overload that accepts wildcard pattern strings like "*.example.com" or "preview-*.shopist.io". Customers currently cannot configure WebView tracking for dynamic hostnames (ephemeral preview URLs, multi-tenant subdomain fleets) — the existing hosts: API only supports exact matches and subdomain-suffix matching.

This is the iOS side of RUM-15826. Browser SDK counterpart: DataDog/browser-sdk#4703

How?

A new optional getAllowedWebViewHostPatterns?() method is injected into the bridge alongside the existing getAllowedWebViewHosts(), which keeps its current shape forever. Browser SDK detects the new method via typeof === 'function' and evaluates patterns using plain string operations — no regex engine involved on any platform.

Patterns with more than one * are dropped with a console warning. Patterns are lowercased. The existing enable(webView:hosts:) path is byte-for-byte unchanged.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes
  • Add Objective-C interface for public APIs - see our guidelines (internal)
  • Run make api-surface when adding new APIs

@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-15826/webview-wildcard-matching branch from 2bfc211 to 3554605 Compare June 2, 2026 13:52
@datadog-prod-us1-6

This comment has been minimized.

@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: 3554605ce8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread DatadogWebViewTracking/Sources/WebViewTracking.swift Outdated
Comment thread DatadogWebViewTracking/Sources/ObjC/WebViewTracking+objc.swift
@barboraplasovska barboraplasovska changed the title [RUM-15826] Add wildcard host pattern matching to WebView tracking [RUM-16633] Add wildcard host pattern matching to WebView tracking Jun 4, 2026
@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-15826/webview-wildcard-matching branch from 3554605 to b5fd77c Compare June 4, 2026 13:01
Comment thread DatadogWebViewTracking/Sources/WebViewTracking.swift
Comment thread CHANGELOG.md Outdated
@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-15826/webview-wildcard-matching branch from c6520c8 to 2e27429 Compare June 5, 2026 08:47

@gonzalezreal gonzalezreal 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.

Could you also update api-surface-objc for the new Obj-C overload?

api-surface-swift has enable(webView:hostPatterns:logsSampleRate:in:), but api-surface-objc still only has the old hosts: overload.

gonzalezreal
gonzalezreal previously approved these changes Jun 5, 2026
@barboraplasovska barboraplasovska requested a review from maxep June 8, 2026 11:25
Comment thread DatadogWebViewTracking/Sources/WebViewTracking.swift Outdated
Comment thread DatadogWebViewTracking/Sources/WebViewTracking.swift

injectUserScript(on: webView, in: core, using: elements, isTraceSampled: isTraceSampled)

core.telemetry.usage(event: .trackWebView)

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.

We can't distinguish the usage of the new vs old API. Should we think about adding a flag usesPatterns to the event?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea! We can do this in a follow-up PR since it required a schema change.

Comment thread DatadogWebViewTracking/Tests/WebViewTrackingTests.swift
@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-15826/webview-wildcard-matching branch from 60ce6a0 to 195ddc5 Compare June 8, 2026 13:18

@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: 195ddc5c8a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +175 to +177
let allowedWebViewHostsString = validPatterns
.map { "\"\($0)\"" }
.joined(separator: ",")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Expose patterns through the bridge's pattern API

When enable(webView:hostPatterns:) is used, these wildcard values are serialized into the existing hosts payload, so the injected bridge still only exposes getAllowedWebViewHosts(). The Browser SDK side distinguishes wildcard patterns via the new optional getAllowedWebViewHostPatterns() hook (leaving getAllowedWebViewHosts() for exact/suffix hosts), so pages on hosts like preview-123.example.com will continue evaluating "preview-*.example.com" as a literal host and the WebView bridge will be disabled for the main use case of this API.

Useful? React with 👍 / 👎.

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.

This is not correct, there's no getAllowedWebViewHostPatterns() in the browser-sdk PR.

gonzalezreal
gonzalezreal previously approved these changes Jun 9, 2026

@gonzalezreal gonzalezreal 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.

LGTM!
One small changelog issue remains: this PR is listed under 3.12.0, which is already released, and it also duplicates the #2859 and #2956 entries.

Could you move the #2963 entry to Unreleased and remove the duplicate lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants