Quick Start¶
This document provides the shortest integration path for 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 respectively in RUM, and obtain the corresponding
appId. - Confirm the reporting address and authentication method:
- Local environment deployment: Prepare
datakitUrl. - Public network DataWay: Prepare
datawayUrlandcliToken. - Confirm that the SDK installation is complete for the project.
Integration Steps¶
- Install
ft_mobile_agent_flutter. - Call
FTMobileFlutter.sdkConfigwhen the application starts. - Initialize
FTRUMManager().setConfig(...), and enable automatic Flutter exception collection. - Add
FTRouteObserver()toMaterialApp.navigatorObservers. - If logs and distributed tracing 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 Integration.
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,
);
// Automatic Flutter exception 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: [
// Automatic page switch collection
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 automatic View 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 distributed tracing, 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, please continue reading Application Integration.
- For explanations of all initialization parameters, please read SDK Initialization.
- For detailed configurations of RUM, Log, and Trace, please read RUM Configuration, Log Configuration, Trace Configuration.
- If you need to integrate Session Replay, please read Flutter Session Replay.
- If you need to monitor H5 pages within Flutter, please continue reading WebView Data Monitoring.
- If your project involves hybrid development of native and Flutter, please continue reading Native and Flutter Hybrid Development.