Skip to content

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:

  1. In Real User Monitoring (RUM), create an Android app and an iOS app, and obtain the corresponding appId for each.
  2. Confirm the reporting URL and authentication method:
  3. Local environment deployment: prepare datakitUrl
  4. Public DataWay: prepare datawayUrl and cliToken
  5. Confirm that the SDK has been installed in the project.

Integration Steps

  1. Install ft_mobile_agent_flutter
  2. Call FTMobileFlutter.sdkConfig when the app starts
  3. Initialize FTRUMManager().setConfig(...) and enable automatic Flutter exception collection
  4. Add FTRouteObserver() to MaterialApp.navigatorObservers
  5. If you need logs and distributed tracing, initialize FTLogger and FTTracer as well
  6. 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 datawayUrl and cliToken with datakitUrl.

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

  1. Keep debug: true enabled and run the app
  2. Open a page, perform a route transition, or make a network request
  3. In the Flutter, Android Studio, and Xcode consoles, confirm that logs related to SDK initialization and data synchronization appear
  4. 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

Feedback

Is this page helpful?