Overview
This package is an extension to the datadog_flutter_plugin
. It allows Real User Monitoring to monitor web views created by the flutter_inappwebview
package and eliminate blind spots in your hybrid Flutter applications.
Warning
This plugin does not currently support Flutter Web
Instrumenting your web views
The RUM Flutter SDK provides APIs for you to control web view tracking when using the flutter_inappwebview
package.
Add both the datadog_inappwebview_tracking
package and the flutter_inappwebview
package to your pubspec.yaml
:
dependencies:
flutter_inappwebview: ^6.1.5
datadog_flutter_plugin: ^2.8.0
datadog_inappwebview_tracking: ^1.0.0
InAppWebView
To instrument an InAppWebView
, add the DatadogInAppWebViewUserScript
to your initialUserScripts
, and call the trackDatadogEvents
extension method during the onWebViewCreated
callback:
InAppWebView(
// Other settings...
initialUserScripts: UnmodifiableListView([
DatadogInAppWebViewUserScript(
datadog: DatadogSdk.instance,
allowedHosts: {'shopist.io'},
),
]),
onWebViewCreated: (controller) async {
controller.trackDatadogEvents(DatadogSdk.instance);
},
)
InAppBrowser
Warning
InAppBrowser
is not tracked on Android 33+ because of this bug. This will be fixed by plugin versions that depends on flutter_inappwebview 6.2.0
.
To instrument an InAppBrowser
, add an override for onBrowserCreated
and call the trackDatadogEvents
extension method on webViewController
, then add a DatadogInAppWebViewUserScript
to the initialUserScripts
when creating your custom InAppBrowser
:
class MyInAppBrowser extends InAppBrowser {
MyInAppBrowser({super.windowId, super.initialUserScripts});
@override
void onBrowserCreated() {
webViewController?.trackDatadogEvents(DatadogSdk.instance);
super.onBrowserCreated();
}
}
// Browser creation
_browser = MyInAppBrowser(
initialUserScripts: UnmodifiableListView(
[
DatadogInAppWebViewUserScript(
datadog: DatadogSdk.instance,
allowedHosts: {'shopist.io'},
),
],
),
);