evently library

Evently - A production-ready Flutter SDK for event tracking and analytics.

Features

  • Clean architecture with separation of concerns
  • Automatic event batching and offline queue
  • Configurable retry logic with exponential backoff
  • Type-safe error handling
  • Structured logging
  • Production-ready with proper abstractions

Usage

Initialization

import 'package:evently/evently.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await EventlyClient.initialize(
    config: EventlyConfig(
      serverUrl: 'https://analytics.example.com',
      apiKey: 'your-api-key',
      environment: 'production',
      debugMode: false,
      batchSize: 20,
      batchIntervalSeconds: 30,
    ),
  );

  runApp(MyApp());
}

Tracking Events

// Simple event
await EventlyClient.instance.logEvent(
  name: 'button_click',
  screenName: 'HomeScreen',
);

// Event with properties
await EventlyClient.instance.logEvent(
  name: 'purchase_completed',
  screenName: 'CheckoutScreen',
  properties: {
    'product_id': '12345',
    'amount': 99.99,
    'currency': 'USD',
  },
  userId: 'user_123',
);

Manual Flush

// Force send all pending events
await EventlyClient.instance.flush();

Classes

ConfigurationFailure
Failure when configuration is invalid.
ConsoleLogger
Default console logger implementation.
Event
Immutable domain entity representing an analytics event.
EventlyClient
Main client for Evently SDK.
EventlyConfig
Configuration class for Evently SDK.
EventlyLogger
Logger interface for Evently SDK.
Failure
Base class for failures (functional error handling). Use this for expected errors that should be handled gracefully.
NetworkFailure
Failure when network operations fail.
SerializationFailure
Failure when serialization fails.
SilentLogger
Silent logger (no-op) for production or when logging is disabled.
StorageFailure
Failure when storage operations fail.
ValidationFailure
Failure when validation fails.

Enums

LogLevel
Log levels for structured logging.

Exceptions / Errors

ConfigurationException
Thrown when SDK is not properly configured.
EventlyException
Base exception for all Evently errors.
NetworkException
Thrown when network operations fail.
SerializationException
Thrown when event serialization/deserialization fails.
StorageException
Thrown when storage operations fail.
ValidationException
Thrown when event validation fails.