analytics_logger

Lightweight analytics event logging for Flutter apps.

Features

  • Queue and batch analytics events before upload
  • Flush queued events on a periodic timer, when batch size is reached, for high-priority events, and when the app is moving to background or detaching
  • Support custom uploaders and route policies
  • Support interceptors for context injection and param sanitization
  • Print debug logs only in debug builds when enabled
  • Use in-memory storage by default, or inject a custom EventStore

Installation

Add the dependency in pubspec.yaml:

dependencies:
  analytics_logger: ^1.0.0

Then run:

flutter pub get

Quick Start

final logger = AnalyticsLogger(
  config: const AnalyticsConfig(
    enableDebugPrint: true,
  ),
  routePolicy: const DefaultRoutePolicy(),
  uploaders: {
    'default': MyUploader(),
  },
);

await logger.init();

await logger.track(
  'page_view',
  params: {'page': 'home'},
);

Storage

analytics_logger uses in-memory storage by default. If you need local persistence, implement EventStore in your app and pass it into AnalyticsLogger.

More

See the example/ directory for a complete integration example.

Libraries

analytics_logger