Quick Start¶
This document provides the shortest path to integrate the Flutter RUM SDK, helping you complete a verifiable data report with minimal steps.
Prerequisites¶
Before starting, please complete the following preparations:
- Create Android and iOS applications in RUM respectively, and obtain the corresponding
appId. - Confirm the reporting address and authentication method:
- Local environment deployment: Prepare
datakitUrl. - Public DataWay: Prepare
datawayUrlandcliToken. - Confirm that the SDK installation is completed in the project.
Integration Steps¶
- Install
ft_mobile_agent_flutter. - Call
FTMobileFlutter.sdkConfigwhen the application starts. - Initialize
FTRUMManager().setConfig(...), and enable Flutter exception automatic collection. - Add
FTRouteObserver()toMaterialApp.navigatorObservers. - If logs and APM are needed, then initialize
FTLoggerandFTTracer. - Confirm in the console that data has been successfully reported.
Install SDK¶
For installation methods, please refer directly to Application Access.
Minimal Initialization Example¶
void main() async {
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
// Use datakitUrl for local environment deployment
await FTMobileFlutter.sdkConfig(
datawayUrl: datawayUrl,
cliToken: cliToken,
debug: true,
);
await FTRUMManager().setConfig(
androidAppId: appAndroidId,
iOSAppId: appIOSId,
enableUserResource: true,
);
// Flutter exception automatic collection
FlutterError.onError = FTRUMManager().addFlutterError;
runApp(const MyApp());
}, (Object error, StackTrace stack) {
FTRUMManager().addError(error, stack);
});
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [
// Automatically collect page switches
FTRouteObserver(),
],
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
If using local environment deployment, replace
datawayUrlandcliTokenwithdatakitUrl.If you need to perform View automatic collection based on named routes, please continue to configure the routing table in
MaterialApp.routes. For detailed methods, please refer to Data Collection Custom Rules.
Optional: Initialize Log and Trace¶
If you also need log collection or APM, you can continue to add the following initialization:
await FTLogger().logConfig(
enableCustomLog: true,
enableLinkRumData: true,
);
await FTTracer().setConfig(
enableAutoTrace: true,
enableLinkRUMData: true,
);
Verify Integration Success¶
- Keep
debug: trueenabled and run the application. - Open a page, perform a route jump, or initiate a network request.
- Confirm in the Flutter, Android Studio, or Xcode console that logs related to SDK initialization and data synchronization appear.
- Return to the Guance console and confirm that corresponding RUM data has appeared in the application.
If further troubleshooting is needed, please refer to Troubleshooting.
Next Steps¶
- For complete installation and initialization instructions, continue reading Application Access.
- For explanations of all initialization parameters, read SDK Initialization.
- For detailed configuration of RUM, Log, and Trace, read RUM Configuration, Log Configuration, Trace Configuration.
- If you need to integrate H5 page monitoring in Flutter, continue reading WebView Data Monitoring.
- If your project involves native and Flutter hybrid development, continue reading Native and Flutter Hybrid Development.