flutter_analytics_mock

Pub License Platform

Mock analytics for testing without sending real data. This package provides a comprehensive mock implementation that supports all Flutter platforms including WASM compatibility.

Features

  • ๐Ÿš€ Mock Analytics Implementation - Test your analytics without sending real data
  • ๐Ÿ“ฑ Multi-Platform Support - iOS, Android, Web, Windows, macOS, Linux
  • ๐ŸŒ WASM Compatible - Full support for Flutter Web with WASM
  • ๐Ÿงช Testing Ready - Designed for unit and integration tests
  • ๐Ÿ“Š Comprehensive Coverage - All major analytics events supported
  • ๐Ÿ”’ Privacy Safe - No data leaves your device during testing

Getting Started

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_analytics_mock: ^0.0.1

Usage

import 'package:flutter_analytics_mock/flutter_analytics_mock.dart';

void main() {
  // Initialize mock analytics
  final analytics = MockAnalytics();
  
  // Track events
  analytics.trackEvent('button_clicked', parameters: {'button_id': 'submit'});
  
  // Track user properties
  analytics.setUserProperty('user_type', 'premium');
  
  // Track screen views
  analytics.trackScreenView('home_screen');
}

Platform Support

Platform Status
iOS โœ… Supported
Android โœ… Supported
Web โœ… Supported
Windows โœ… Supported
macOS โœ… Supported
Linux โœ… Supported
WASM โœ… Supported

Testing

This package is designed to work seamlessly with your existing test suite:

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_analytics_mock/flutter_analytics_mock.dart';

void main() {
  group('Analytics Tests', () {
    late MockAnalytics analytics;
    
    setUp(() {
      analytics = MockAnalytics();
    });
    
    test('should track events', () {
      analytics.trackEvent('test_event');
      expect(analytics.events, contains('test_event'));
    });
  });
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.