atatus_inappwebview_tracking 1.0.4
atatus_inappwebview_tracking: ^1.0.4 copied to clipboard
A package for tracking Atatus sessions in webviews create with flutter_inappwebview
Overview #
This package is an extension to the atatus_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 atatus_inappwebview_tracking package and the flutter_inappwebview package to your pubspec.yaml:
dependencies:
flutter_inappwebview: ^6.1.5
atatus_flutter_plugin: ^3.0.0
atatus_inappwebview_tracking: ^1.0.1
InAppWebView #
To instrument an InAppWebView, add the AtatusInAppWebViewUserScript to your initialUserScripts, and call the trackAtatusEvents extension method during the onWebViewCreated callback:
InAppWebView(
// Other settings...
initialUserScripts: UnmodifiableListView([
AtatusInAppWebViewUserScript(
atatus: AtatusSdk.instance,
allowedHosts: {'shopist.io'},
),
]),
onWebViewCreated: (controller) async {
controller.trackAtatusEvents(AtatusSdk.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 trackAtatusEvents extension method on webViewController, then add a AtatusInAppWebViewUserScript to the initialUserScripts when creating your custom InAppBrowser:
class MyInAppBrowser extends InAppBrowser {
MyInAppBrowser({super.windowId, super.initialUserScripts});
@override
void onBrowserCreated() {
webViewController?.trackAtatusEvents(AtatusSdk.instance);
super.onBrowserCreated();
}
}
// Browser creation
_browser = MyInAppBrowser(
initialUserScripts: UnmodifiableListView(
[
AtatusInAppWebViewUserScript(
atatus: AtatusSdk.instance,
allowedHosts: {'shopist.io'},
),
],
),
);