datadog_inappwebview_tracking 1.0.1 copy "datadog_inappwebview_tracking: ^1.0.1" to clipboard
datadog_inappwebview_tracking: ^1.0.1 copied to clipboard

A package for tracking Datadog sessions in webviews create with flutter_inappwebview

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
copied to clipboard

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);
  },
)
copied to clipboard

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'},
      ),
    ],
  ),
);
copied to clipboard
1
likes
160
points
1.1k
downloads

Publisher

verified publisherdatadoghq.com

Weekly Downloads

2024.09.08 - 2025.03.23

A package for tracking Datadog sessions in webviews create with flutter_inappwebview

Homepage
Repository (GitHub)
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

datadog_flutter_plugin, flutter, flutter_inappwebview, plugin_platform_interface

More

Packages that depend on datadog_inappwebview_tracking