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.
flutter pub add mode_metrics --hosted-url https://gotmode.com/sdk/pubOr add it to pubspec.yaml yourself.
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.
| File | Version | SHA-256 |
|---|---|---|
0.1.0.tar.gz | 0.1.0 | 8a4cbd5a3d809a10996e43a0409d34362b1046ea4c69391a8ce660447727300b |
Start
Call Mode.init before runApp with your public key and tracking hostname, both from Setup.
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.
Events and people
Capture what matters in your app, and name the person once they sign in.
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.
What is captured automatically
Every event below arrives with no code beyond init, the navigator observer and the tap wrapper.
| Event | When |
|---|---|
$app_installed, $app_updated | The first start, and the first start after the version or build changed |
$app_opened | A cold start and every return to the foreground, with the link or the notification that opened it |
$app_backgrounded | The app leaves the foreground, with the time it was in front |
$app_quit, $window_focus, $window_blur | A desktop app quits, or its window gains or loses focus |
$screen | A named route is shown, with the previous screen and how long it was shown |
$deep_link_opened | A link opens the app or reaches it while it runs |
$click, $rage_click | Taps on buttons, tiles, switches and other controls inside ModeTouchCapture |
$exception | An 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.
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').
Deep links and attribution
A link that opens your app counts like a landing on your site, so campaigns and Mode links get credit for installs and opens.
Links that reach the app through Flutter's deep linking are captured at once. With a package such as app_links, pass each link to Mode.openUrl(uri). Before anything is kept, parameters that carry a secret (tokens, passwords, codes, keys, signatures, sessions and magic links) are removed and any email becomes [email]. Campaign parameters, ad click ids and the Mode click id become the first and last touch of the person.
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.
// 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');
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.
Consent and opt out
Start with consent pending, and nothing is written to the device or sent until the person answers.
await Mode.init(key, const ModeOptions(apiHost: host, consent: ModeConsent.pending)); Mode.setConsent(ModeConsent.granted); Mode.updateConsent(adStorage: false); Mode.optOut();
Pending holds up to 200 events in memory. Denied drops events and deletes what was stored. Without ad storage consent, ad click ids are left out. An opt out is remembered on the device and stops every send until Mode.optIn().
Surveys
The surveys you build in Mode Metrics, shown over the screens they target in your app.
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.
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.
Session recordings
The app's screens and taps recorded as wireframes, played in Recordings beside web visits.
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.
Delivery
Events wait on the device and are sent in batches, so nothing is lost offline and nothing is counted twice.
| Setting | Value |
|---|---|
| Batches | Every second, at once at 50 events, and when the app goes to the background |
| Queue | Up to 1,000 events stored on the device |
| Retries | From 1 second to 5 minutes, with the same event ids |
| Flags | flags: true, then Mode.isFeatureEnabled('new_checkout') |
| Shutdown | Mode.shutdown() sends what is queued and removes every listener |