Flutter Application Integration¶
Collect metrics data from various Flutter applications and analyze application performance visually.
Reading Path¶
- First-time integration: Start with Quick Start
- Complete integration: Continue reading this document
- Initialization parameters: Refer to SDK Initialization, RUM Configuration, Log Configuration, Trace Configuration
- Custom capabilities: Refer to Custom Tag Usage, Data Collection Custom Rules, Data Collection Desensitization
- Advanced scenarios: Refer to WebView Data Monitoring, Native and Flutter Hybrid Development, Publish Package Related Configuration
- Troubleshooting: Refer to Troubleshooting
- Data model: Refer to Application Data Collection
Prerequisites¶
Note: If you have enabled the RUM Headless service, the prerequisites are automatically configured for you. You can proceed directly with application integration.
- Install DataKit
- Configure the RUM Collector
- Configure DataKit to be accessible via the public network and install the IP Geolocation database
Application Integration¶
Note
The current Flutter version only supports Android and iOS platforms.
- Navigate to RUM > Create > Android/iOS
- Create two separate applications for Flutter Android and Flutter iOS to receive RUM data from the Android and iOS platforms respectively
- Enter the corresponding application name and application ID for each platform's application
-
Choose the application integration method:
- Public DataWay: Directly receives RUM data without installing the DataKit collector
- Local environment deployment: Receives RUM data after meeting the prerequisites
Installation¶
Pub.Dev: ft_mobile_agent_flutter
Source Code: https://github.com/GuanceCloud/datakit-flutter
Demo: https://github.com/GuanceCloud/datakit-flutter/example
Execute the following command in your project directory:
This will add the dependency to your package's pubspec.yaml:
dependencies:
ft_mobile_agent_flutter: [latest_version]
# For Flutter 2.0 compatibility, use the following reference method
ft_mobile_agent_flutter:
git:
url: https://github.com/GuanceCloud/datakit-flutter.git
ref: [github_legacy_lastest_tag]
Import it in your Dart code:
Additional Android Integration Configuration¶
- Configure the Gradle Plugin ft-plugin for collecting App launch events and Android Native-related events (page navigation, click events, Native network requests, WebView data)
- To count launch times and measure launch duration, you need to customize the
Applicationand declare it inAndroidManifest.xml
import io.flutter.app.FlutterApplication
/**
* If you need to count [Launch Times] and measure [Launch Duration], add a custom Application here.
*/
class CustomApplication : FlutterApplication() {
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cloudcare.ft.mobile.sdk.agent_example">
<application android:name=".CustomApplication">
//...
</application>
</manifest>
Detailed Configuration Entries¶
Advanced Scenarios¶
- Custom Tag Usage
- Data Collection Custom Rules
- Data Collection Desensitization
- WebView Data Monitoring
- Native and Flutter Hybrid Development
- Publish Package Related Configuration
Conflict Field Description¶
- Special key:
track_id, used for tracking functionality - When a user adds a custom tag via
globalContextthat conflicts with an SDK's built-in tag, the SDK's tag value will override the user-set value - It is recommended to add a project abbreviation prefix to tag names, e.g.,
df_tag_name - For
keyvalues used in the project, refer to the Android constant definitions: Constants.java