One-line screen-journey analytics for Flutter (iOS & Android) — the AnalyticsDrop iOS SDK behavior and wire format, in Dart.
From pub.dev:
# pubspec.yaml
dependencies:
analyticsdrop: ^0.1.0Or straight from GitHub:
# pubspec.yaml
dependencies:
analyticsdrop:
git:
url: https://github.com/FlywheelStudio/analyticsdrop-sdk-flutter.gitflutter pub getimport 'package:flutter/material.dart';
import 'package:analyticsdrop/analyticsdrop.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await AnalyticsDrop.start(
apiKey: 'ad_test_…',
endpoint: Uri.parse('http://localhost:3100'),
debug: true,
);
AnalyticsDrop.identify('cust_123');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
// Automatic screen capture:
navigatorObservers: [AnalyticsDropNavigatorObserver()],
// …
);
}
}AnalyticsDropNavigatorObserver captures a screen view on every route push/pop/replace.
The route's settings.name becomes the screen id, so named routes (or explicit
RouteSettings(name: …) on MaterialPageRoute) give the best names. Unnamed routes
fall back to their route type.
AnalyticsDrop.track('purchase', properties: {'value': 9.99, 'plan': 'pro'});
AnalyticsDrop.setScreenName('Checkout'); // exact-name escape hatch (manual screen view)| Method | Description |
|---|---|
AnalyticsDrop.start({apiKey, endpoint?, debug}) |
Initialize before runApp. |
AnalyticsDrop.identify(userId) |
Link an external user id. |
AnalyticsDrop.track(event, {properties}) |
Manual event; property values are String/num/bool. |
AnalyticsDrop.setScreenName(name) |
Manual screen view. |
AnalyticsDropNavigatorObserver() |
Add to MaterialApp.navigatorObservers. |
Sessions (30 s background grace), batching (20 events / 30 s / on background),
screen-view debounce, crash-recovery persistence, and the gzip POST /v1/events
transport (2 retries, 1 s/2 s backoff) all match the iOS SDK.
- Persistence uses
path_provider(the only dependency) to resolve a writable directory. iOS uses the Keychain (anonymous id) and Caches (queue) natively, so the anonymous id survives reinstall on iOS but is per-install here. - Device context
appVersion/builddefault to"0"; addpackage_info_pluswiring if you need real values.
example/ is an auto-driving harness (Home → Detail → Paywall → Checkout →
purchase) that exercises the SDK end-to-end:
cd example
flutter runMIT — see LICENSE.
AnalyticsDrop is a product of Flywheel Studio.