Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnalyticsDrop Flutter SDK

One-line screen-journey analytics for Flutter (iOS & Android) — the AnalyticsDrop iOS SDK behavior and wire format, in Dart.

Install

From pub.dev:

# pubspec.yaml
dependencies:
  analyticsdrop: ^0.1.0

Or straight from GitHub:

# pubspec.yaml
dependencies:
  analyticsdrop:
    git:
      url: https://github.com/FlywheelStudio/analyticsdrop-sdk-flutter.git
flutter pub get

Usage

import '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()],
      // …
    );
  }
}

Screen capture

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.

Manual events

AnalyticsDrop.track('purchase', properties: {'value': 9.99, 'plan': 'pro'});
AnalyticsDrop.setScreenName('Checkout'); // exact-name escape hatch (manual screen view)

API

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.

Notes vs. iOS

  • 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/build default to "0"; add package_info_plus wiring if you need real values.

Example

example/ is an auto-driving harness (Home → Detail → Paywall → Checkout → purchase) that exercises the SDK end-to-end:

cd example
flutter run

License

MIT — see LICENSE.


AnalyticsDrop is a product of Flywheel Studio.

About

One-line screen-journey analytics for Flutter (iOS & Android) — AnalyticsDrop SDK

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages