Documentation

Flutter SDK.

Screens, opens, links, pushes, errors and taps from your Flutter app, linked to the same people as your site.

Flutter

Install

One package for iOS, Android, macOS, Windows, Linux and Flutter web. It sends to your project's own tracking hostname, in the same format as your site, so app and site events land in the same people and reports.

shell
flutter pub add mode_metrics --hosted-url https://gotmode.com/sdk/pub

Or add it to pubspec.yaml yourself.

yaml
dependencies:
  mode_metrics:
    hosted: https://gotmode.com/sdk/pub
    version: ^0.1.0

It needs Flutter 3.41 or later.

Mode serves its SDKs itself, not from a public package registry. A published version never changes, and every file and its SHA-256 is listed in SHA256SUMS.

FileVersionSHA-256
0.1.0.tar.gz0.1.08a4cbd5a3d809a10996e43a0409d34362b1046ea4c69391a8ce660447727300b
Flutter

Start

Call Mode.init before runApp with your public key and tracking hostname, both from Setup.

dart
Future<void> main() async {
  await Mode.init('YOUR_INGEST_KEY', const ModeOptions(apiHost: 'https://m.example.com'));
  runApp(ModeTouchCapture(
    child: MaterialApp(navigatorObservers: [ModeNavigatorObserver()], home: const HomeScreen()),
  ));
}

There is no built-in host. Without apiHost, init throws in a debug build and does nothing in a release build. Calls made before init finishes are kept and run once it has.

Flutter

Events and people

Capture what matters in your app, and name the person once they sign in.

dart
Mode.capture('added_to_cart', {'sku': 'tee-black-m', 'price': 24});
Mode.identify('user_42', set: {'plan': 'pro'});
Mode.group('company', 'acme', set: {'seats': 25});
Mode.register({'app_theme': 'dark'});
Mode.reset(); // on logout

A different user than the one stored starts a new person. Person properties set before identify wait for it. An empty id, one over 200 bytes, or a placeholder such as null or guest is never sent. alias, setPersonProperties, unsetPersonProperties, registerOnce, registerForSession and unregister work as on the web.

Flutter

What is captured automatically

Every event below arrives with no code beyond init, the navigator observer and the tap wrapper.

EventWhen
$app_installed, $app_updatedThe first start, and the first start after the version or build changed
$app_openedA cold start and every return to the foreground, with the link or the notification that opened it
$app_backgroundedThe app leaves the foreground, with the time it was in front
$app_quit, $window_focus, $window_blurA desktop app quits, or its window gains or loses focus
$screenA named route is shown, with the previous screen and how long it was shown
$deep_link_openedA link opens the app or reaches it while it runs
$click, $rage_clickTaps on buttons, tiles, switches and other controls inside ModeTouchCapture
$exceptionAn uncaught error from the framework, the platform dispatcher or the isolate

Every event carries the locale, time zone, screen and window size, platform, app version and current screen. The first event of each session carries the device (OS, model, device type, dark mode, font scale and the like). Each autocapture can be turned off in ModeAutocapture or from the project.

Flutter

Screens

ModeNavigatorObserver names each screen from its route.

Add it to navigatorObservers, or with go_router to the router's observers and those of each shell route. A route needs a name, from RouteSettings or from the screenName option. Dialogs and sheets are left out unless capturePopupRoutes is on. For a screen outside the navigator, call Mode.screen('Checkout').

Flutter

Push notifications

Notifications and the push token are captured on Android and iOS with no code, with or without firebase_messaging.

The package carries a small Android and iOS part of its own. On Android it sees every Firebase message the app receives, in the foreground, the background or with the app closed, the tap on a Firebase notification that starts or reaches the app, and the FCM token when the app ships Firebase Messaging and leaves its automatic init on. On iOS it sees notifications shown while the app runs and every tap, whichever object handles them, and the APNs token. What arrives while Flutter is not running is kept on the device and sent at the next start, with the time it arrived.

Each event keeps the message id and the campaign (mode_campaign, utm_campaign, campaign or the Firebase campaign label), the channel on Android, the category and thread on iOS, and whether the push was silent. Never the title or the body. A link in a tapped notification's data is read as a landing, and the tap that opened the app marks that $app_opened with push. The same message seen twice counts once, a token is reported once until it changes, and the token itself is sent only with sendPushToken: true. ModeAutocapture(push: false) turns it off.

dart
// Only for a notification the package cannot see, such as one a service extension handles
Mode.pushReceived(data, foreground: false);
Mode.pushOpened(data);
Mode.registerPushToken(token, 'webpush');
Flutter

Errors and logs

Uncaught errors appear in Errors with their stack and the last screens and events before them.

Handlers you set before init keep running. Report a caught error with Mode.captureException(error, stack: stack), and wrap code in Mode.runZonedGuarded to capture a zone's errors. Mode.log('warn', 'payment retried') sends a log line, and the console autocapture sends debugPrint output. Logs are scrubbed of emails and long numbers.

Flutter

Surveys

The surveys you build in Mode Metrics, shown over the screens they target in your app.

Coming in the next release. The published package doesn't include surveys yet. ModeSurveys and the survey calls will be listed here once they are published.

In the app, a survey will ask one question at a time with its own labels, follow its URL rule against the current screen, keep to its flag and how often it repeats, ask only while consent is granted, and send $survey_shown, $survey_dismissed, and $survey_response.

Flutter

Taps and privacy

A tapped control is described by its type, key, label and visible text, never by what a person typed.

Emails and long numbers in a label become *. Password, card and one time code fields are never captured. maskText: true leaves all text out, ModeMask leaves text out of part of your app, and ModeIgnore keeps part of it out entirely.

Flutter

Session recordings

The app's screens and taps recorded as wireframes, played in Recordings beside web visits.

Coming in the next release. The published package doesn't record sessions yet. The recording option and the ModeUnmask and ModeBlock widgets will be listed here once they are published.

Recordings will mask every text, image, and field value until you turn it on in the source's recording settings, never send password, card, or one time code fields, and record nothing in the background, before consent where it is required, or after an opt out.

Flutter

Delivery

Events wait on the device and are sent in batches, so nothing is lost offline and nothing is counted twice.

SettingValue
BatchesEvery second, at once at 50 events, and when the app goes to the background
QueueUp to 1,000 events stored on the device
RetriesFrom 1 second to 5 minutes, with the same event ids
Flagsflags: true, then Mode.isFeatureEnabled('new_checkout')
ShutdownMode.shutdown() sends what is queued and removes every listener

Let AI run your marketing.

Mode Agent does the daily work. You approve the spend.

Get early access