flutter_analytics_mock
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.