[RUM-16633] Add wildcard host pattern matching to WebView tracking#2963
Conversation
2bfc211 to
3554605
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 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".
3554605 to
b5fd77c
Compare
c6520c8 to
2e27429
Compare
gonzalezreal
left a comment
There was a problem hiding this comment.
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.
|
|
||
| injectUserScript(on: webView, in: core, using: elements, isTraceSampled: isTraceSampled) | ||
|
|
||
| core.telemetry.usage(event: .trackWebView) |
There was a problem hiding this comment.
We can't distinguish the usage of the new vs old API. Should we think about adding a flag usesPatterns to the event?
There was a problem hiding this comment.
Good idea! We can do this in a follow-up PR since it required a schema change.
…f a separate method
60ce6a0 to
195ddc5
Compare
There was a problem hiding this comment.
💡 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".
| let allowedWebViewHostsString = validPatterns | ||
| .map { "\"\($0)\"" } | ||
| .joined(separator: ",") |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
This is not correct, there's no getAllowedWebViewHostPatterns() in the browser-sdk PR.
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 existinghosts: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 existinggetAllowedWebViewHosts(), which keeps its current shape forever. Browser SDK detects the new method viatypeof === '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 existingenable(webView:hosts:)path is byte-for-byte unchanged.Review checklist
make api-surfacewhen adding new APIs