The Alibaba Cloud Real User Monitoring (RUM) Flutter plugin supports the Android, iOS, and HarmonyOS platforms.
Version requirements
Flutter: 3.0.0+
iOS: 12.0+
Android: 7.0+
Step 1: Integrate the Flutter plugin
Add the dependency to the pubspec.yaml configuration file.
dependencies: flutter: sdk: flutter alibabacloud_rum_flutter_plugin: ^2.1.0In the root directory of your Flutter project, run the following command to install the plugin.
flutter packages getIf you have an iOS application, run the following command in the
iosdirectory of your project to install the pods.pod installInitialize the Flutter SDK.
Import the following package in the
main.dartfile.import 'package:alibabacloud_rum_flutter_plugin/alibabacloud_rum_flutter_plugin.dart';Initialize the SDK.
void main() { // Comment out the original runApp() method // runApp(MyApp()); // (Required) Initialize the SDK AlibabaCloudRUM().start(MyApp()); // (Optional) Set a custom username AlibabaCloudRUM().setUserName("xxxxxx"); }
(Optional) Collect action events.
The RUM Flutter plugin supports the collection of action events, such as clicks. To collect user click events, you can configure and use
AlibabaCloudActionCapture. The following code shows an example:class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return AlibabaCloudActionCapture( child: Scaffold( appBar: AppBar( title: const Text('AlibabaCloudRUM'), ), body: // Your other code )); } }Verify the plugin integration.
Start the Flutter application. If the
DEBUG CONSOLEdisplays the message[INFO][AlibabaCloudRUM]: alibabacloud_rum_flutter_plugin start success, the SDK has been successfully integrated.The following output is an example:
flutter: [2024-05-27 16:43:39][INFO][AlibabaCloudRUM]: alibabacloud_rum_flutter_plugin start success
Step 2: Integrate native SDKs
Integrating the Alibaba Cloud RUM SDK into a Flutter project requires you to integrate both the Flutter plugin and the native SDKs for Android, iOS, and HarmonyOS. For integration instructions, see the following documents:
Android: Connect to an Android application.