Quick Start¶
This article provides the shortest integration path for the Flutter RUM SDK to help you complete a verifiable data reporting flow with minimal steps.
The app supports Agent automatic integration and manual integration. The following steps describe the minimal configuration for manual integration.
Prerequisites¶
Before you begin, complete the following preparations:
- In Real User Monitoring (RUM), create an Android app and an iOS app, and obtain the corresponding
appIdfor each. - Confirm the reporting URL and authentication method:
- Local environment deployment: prepare
datakitUrl - Public DataWay: prepare
datawayUrlandcliToken - Confirm that the SDK has been installed in the project.
Integration Steps¶
- Install
ft_mobile_agent_flutter - Call
FTMobileFlutter.sdkConfigwhen the app starts - Initialize
FTRUMManager().setConfig(...)and enable automatic Flutter exception collection - Add
FTRouteObserver()toMaterialApp.navigatorObservers - If you need logs and distributed tracing, initialize
FTLoggerandFTTraceras well - Confirm in the console that data has been reported successfully
Install the SDK¶
For installation methods, refer directly to App 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: [
// Automatically collect page transitions
FTRouteObserver(),
],
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
If you use local environment deployment, replace
datawayUrlandcliTokenwithdatakitUrl.If you need automatic View tracking based on named routes, continue to configure the route table in
MaterialApp.routes. For details, see Custom Tracking Rules.
Optional: Initialize Log and Trace¶
If you also need log collection or distributed tracing, you can append the following initialization:
await FTLogger().logConfig(
enableCustomLog: true,
enableLinkRumData: true,
);
await FTTracer().setConfig(
enableAutoTrace: true,
enableLinkRUMData: true,
);
Verify the Integration¶
- Keep
debug: trueenabled and run the app - Open a page, perform a route transition, or make a network request
- In the Flutter, Android Studio, and Xcode consoles, confirm that logs related to SDK initialization and data synchronization appear
- Return to the Guance console and confirm that the corresponding RUM data has appeared in the app
If you need further troubleshooting, see Troubleshooting.
Next Steps¶
- For complete installation and initialization instructions, continue reading App Integration
- For descriptions of all initialization parameters, see SDK Initialization
- For detailed configuration of RUM, Log, and Trace, see RUM Configuration, Log Configuration, and Trace Configuration
- If you need to integrate Session Replay, see Flutter Session Replay
- If you need to integrate H5 page monitoring in Flutter, continue reading WebView Data Monitoring
- If your project uses hybrid native and Flutter development, continue reading Hybrid Native and Flutter Development