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 Masking
- 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 directly integrate the application.
- 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.
- Go to RUM > Create > Android/iOS
- Create two applications for Flutter Android and Flutter iOS respectively, to receive RUM data from the Android and iOS platforms separately
- Enter the corresponding application name and application ID for each platform's application
-
Choose the application integration method:
- Public Network 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 Address: https://github.com/GuanceCloud/datakit-flutter
Demo Address: https://github.com/GuanceCloud/datakit-flutter/example
Execute the following command in your project directory:
This will add the dependency in 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 Configuration for Android Integration¶
- 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 [Launch Duration], add a custom Application here
*/
class CustomApplication : FlutterApplication() {
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ft.sdk.flutter.agent_example">
<application android:name=".CustomApplication">
//...
</application>
</manifest>
Detailed Configuration Entries¶
Advanced Scenarios¶
- Custom Tag Usage
- Data Collection Custom Rules
- Data Collection Masking
- 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.,
custom_tag_name -
The
keyvalues used in the project can be referenced from the Android constant definitions: Constants.java