-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUMM-1791 WebEventConsumers added #683
RUMM-1791 WebEventConsumers added #683
Conversation
Sources/Datadog/FeaturesIntegration/WebView/WebRUMEventConsumer.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WKUserContentController+Datadog.swift
Outdated
Show resolved
Hide resolved
1fec047
to
6091458
Compare
6091458
to
aeab8c4
Compare
Sources/Datadog/FeaturesIntegration/WebView/WKUserContentController+Datadog.swift
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WebRUMEventConsumer.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WKUserContentController+Datadog.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WebRUMEventConsumer.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WebLogEventConsumer.swift
Outdated
Show resolved
Hide resolved
Optionals to non-optionals, non-optionals to optionals ashes to ashes, dust to dust...
Sources/Datadog/FeaturesIntegration/WebView/WKUserContentController+Datadog.swift
Show resolved
Hide resolved
WKUserContentController_DatadogTests improved
fbe03a6
to
5b03879
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs answers on tracking consent for webview events and more logs on eventual inconsistency of the solution. Currently we only addresses the happy scenario (both Logs and RUM enabled, tracking consent granted and receiving only known events).
Sources/Datadog/FeaturesIntegration/WebView/WebLogEventConsumer.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/FeaturesIntegration/WebView/WKUserContentController+Datadog.swift
Show resolved
Hide resolved
9abf1d7
to
e10f099
Compare
if eventType == Constants.eventTypeLog { | ||
logEventConsumer.consume(event: wrappedEvent, eventType: eventType) | ||
try logEventConsumer?.consume(event: wrappedEvent, eventType: eventType) | ||
} else { | ||
rumEventConsumer.consume(event: wrappedEvent, eventType: eventType) | ||
try rumEventConsumer?.consume(event: wrappedEvent, eventType: eventType) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we pass Browser events to Logging / RUM feature storage, in case of Logging or RUM being disabled we will be sending Browser SDK events to void. This will result with losing observability and entire set of telemetry from webviews, depending on native SDK configuration. This requires additional handling - @mariusc83 @buranmert @xgouchet what's our strategy for this?
I see 3 options:
- we can send events to their own storage - independent from Logging / RUM feature;
- we can inform the user on dropping event due to misconfiguration:
if eventType == Constants.eventTypeLog {
if let logEventConsumer = logEventConsumer {
try logEventConsumer.consume(event: wrappedEvent, eventType: eventType)
} else {
userLogger.warn(/* warn that event will be lost because Logging is disabled in native SDK */)
}
} else {
if let rumEventConsumer = rumEventConsumer {
try rumEventConsumer(event: wrappedEvent, eventType: eventType)
} else {
userLogger.warn(/* warn that event will be lost because RUM is disabled in native SDK */)
}
}
- we can register selectively for receiving only Logs / only RUM / both Logs and RUM events from Browser SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ we decided to go with userLogger.warn
option at today's daily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ncreated should we warn the user every time a new event is received (that might spam their console)?
or only once when WebEventConsumer
is created?
Sources/Datadog/FeaturesIntegration/WebView/WebRUMEventConsumer.swift
Outdated
Show resolved
Hide resolved
WebRUMEvents are decorated as raw JSONs instead of serializing them into RUMDataModels
guard let context = context, | ||
context.sessionID != .nullUUID else { | ||
return event | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Given native RUM session rejected by sampler, when receiving event from WebView, it is sent anyway" seems to be critical (it impacts user billing) and not very obvious behaviour (in case of RUM disabled we drop events, but we send events no matter of RUM sampling). I don't see it covered in unit tests, meaning we can easily overlook it and change unawarely.
Missing test case added: sampled out native session
|
||
private func map(event: JSON, with context: RUMContext?) -> JSON { | ||
guard let context = context, | ||
context.sessionID != .nullUUID else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.sessionID == .nullID
when the session is sampled-out
What and why?
Datadog
browser-sdk
integration will send log and RUM events to the native SDK and these events will be decorated with the contextual information of the native app.That way any app with web view can display its users' session in the same timeline, native + webview.
How?
Once the message is passed from
browser-sdk
, a JS script will catch it and pass it to eitherWebLogEventConsumer
orWebRUMEventConsumer
.Then they will add information to events and persist them in the filesystem where they wait to be uploaded to Datadog.
Review checklist