mostly_good_metrics_flutter library

Official Flutter SDK for MostlyGoodMetrics.

Simple, privacy-focused analytics for your Flutter applications.

Quick Start

import 'package:mostly_good_metrics_flutter/mostly_good_metrics_flutter.dart';

// Initialize the SDK
await MostlyGoodMetrics.configure(
  MGMConfiguration(
    apiKey: 'your-api-key',
    appVersion: '1.0.0',
  ),
);

// Track events
MostlyGoodMetrics.track('button_clicked', properties: {'button_id': 'signup'});

// Identify users with optional profile data
MostlyGoodMetrics.identify(
  'user-123',
  profile: UserProfile(email: 'user@example.com', name: 'Jane Doe'),
);

Classes

EventContext
Context information shared across events in a batch.
EventsPayload
Represents the payload sent to the API.
EventStorage
Abstract interface for event storage.
FileEventStorage
File-based event storage implementation. Uses JSON file storage for events and SharedPreferences for metadata.
HttpNetworkClient
HTTP-based network client implementation.
InMemoryEventStorage
In-memory event storage for testing.
InMemoryStateStorage
In-memory state storage for testing.
MGMConfiguration
Configuration options for the MostlyGoodMetrics SDK.
MGMEvent
Represents an analytics event to be tracked.
MockNetworkClient
Mock network client for testing.
MostlyGoodMetrics
The main MostlyGoodMetrics SDK class.
NetworkClient
Abstract interface for the network client.
PreferencesStateStorage
SharedPreferences-based state storage implementation.
StateStorage
Abstract interface for persistent state storage.
UserProfile
User profile data for the identify() call.

Enums

MGMErrorType
Error types that can occur in the SDK.
SendResult
Result of sending events to the API.

Exceptions / Errors

MGMError
Represents an error from the SDK.