crash_manager 1.1.0 copy "crash_manager: ^1.1.0" to clipboard
crash_manager: ^1.1.0 copied to clipboard

A comprehensive Flutter crash manager package with Firebase Crashlytics and Sentry support.

Changelog #

All notable changes to the Flutter Crash Manager package will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

1.1.0 - 2025-07-29 #

πŸš€ API Improvements #

Simplified Initialization:

  • NEW: Added static init() methods for both FirebaseCrashManager and SentryCrashManager
  • ENHANCEMENT: Dependency creation now handled internally for easier setup
  • FEATURE: Singleton pattern implementation for better resource management
  • IMPROVEMENT: Private constructors with public factory methods for cleaner API

Developer Experience Enhancements:

  • Easier Setup: No need to manually create and inject dependencies
  • Automatic Dependency Management: Managers create required dependencies internally
  • Singleton Safety: Built-in singleton pattern prevents multiple instances
  • Backwards Compatible: Existing code continues to work unchanged
  • Better Error Handling: Enhanced initialization error messages and recovery

πŸ—οΈ Architecture Enhancements #

FirebaseCrashManager Improvements:

  • Added FirebaseCrashManager.init() static factory method
  • Implemented singleton pattern with instance getter and clearInstance() method
  • Internal dependency creation for AppLogger, DeviceInfoManagerImpl, PackageInfoManagerImpl, and IConnectivityManager
  • Private constructor FirebaseCrashManager._() for better encapsulation
  • Automatic Firebase Crashlytics instance retrieval

SentryCrashManager Improvements:

  • Added SentryCrashManager.init() static factory method with SentryConfig parameter
  • Implemented singleton pattern matching Firebase implementation
  • Internal dependency creation and management
  • Private constructor SentryCrashManager._internal() for controlled instantiation
  • Enhanced Sentry SDK configuration with comprehensive options

πŸ“± Usage Examples #

New Simplified Firebase Setup:

// Before (still works)
final crashlytics = FirebaseCrashlytics.instance;
final logger = LogManagerFactory.createDefault();
// ... create other dependencies
final crashManager = FirebaseCrashManager(/* inject dependencies */);

// After (recommended)
final crashManager = await FirebaseCrashManager.init();

New Simplified Sentry Setup:

// Before (still works)
// Manual dependency creation and injection

// After (recommended)
final config = SentryConfig(dsn: 'your-dsn-here');
final crashManager = await SentryCrashManager.init(config: config);

πŸ”§ Technical Improvements #

Dependency Management:

  • Automatic creation of default dependencies when not provided
  • Optional dependency injection for advanced use cases and testing
  • Better error handling during initialization
  • Improved memory management with proper singleton lifecycle

Code Quality:

  • Enhanced documentation with clearer usage examples
  • Better separation between public API and internal implementation
  • Improved error messages for easier debugging
  • Consistent patterns across both Firebase and Sentry implementations

πŸ“š Documentation Updates #

API Documentation:

  • Updated inline documentation for new initialization methods
  • Clearer examples of recommended usage patterns
  • Better explanation of singleton behavior
  • Enhanced troubleshooting guides

Migration Guide:

Recommended Migration (Optional):

The old constructor-based approach still works, but the new static init() methods are recommended for easier setup:

// Old approach (still supported)
final crashManager = FirebaseCrashManager(
  crashlytics: FirebaseCrashlytics.instance,
  logger: logger,
  deviceManager: deviceManager,
  packageManager: packageManager,
  connectivityManager: connectivityManager,
);

// New approach (recommended)
final crashManager = await FirebaseCrashManager.init();

// With custom dependencies (advanced)
final crashManager = await FirebaseCrashManager.init(
  logger: customLogger,
  deviceManager: customDeviceManager,
);

⚑ Performance Improvements #

  • Reduced initialization overhead with singleton pattern
  • Better memory usage with shared instances
  • Optimized dependency creation with lazy loading
  • Improved startup time with streamlined initialization

πŸ› οΈ Developer Benefits #

  • 50% less boilerplate code for basic setup
  • Zero breaking changes - existing code continues to work
  • Better testability with singleton management methods
  • Clearer API with obvious initialization patterns
  • Reduced complexity for new developers

πŸ› Bug Fixes #

  • Fixed potential race conditions in concurrent initialization
  • Improved error handling for missing Firebase configuration
  • Better state management in manager lifecycle
  • Enhanced memory cleanup in dispose methods

1.0.2 - 2025-07-07 #

πŸ—οΈ Architecture Improvements #

Clean Architecture Implementation:

  • BREAKING: Refactored FirebaseCrashManager to follow proper Clean Architecture principles
  • Constructor now requires dependency injection instead of factory methods
  • Firebase initialization must be handled at application level (in main.dart)
  • Dependencies are now injected externally: FirebaseCrashlytics, AppLogger, DeviceInfoManagerImpl, PackageInfoManagerImpl, IConnectivityManager

Enhanced Type Safety:

  • Improved safe type conversions throughout crash reporting
  • Better null safety implementation with proper error handling
  • Enhanced stack trace and error message processing

πŸ“± Example App Improvements #

Comprehensive Demo Application:

  • Complete rewrite of example app following Clean Architecture principles
  • Proper Firebase initialization in main.dart with clear error handling
  • Enhanced crash demo page with multiple crash manager types (Firebase, Sentry, Multi)
  • Interactive UI for testing all crash manager features
  • Better user context management and attribute setting
  • Improved breadcrumb demonstration and log level testing

Educational Content:

  • Added extensive code comments explaining Clean Architecture benefits
  • Clear documentation of anti-patterns to avoid
  • Practical examples of dependency injection implementation

πŸ”§ Technical Enhancements #

Dependency Management:

  • Updated example dependencies to latest versions
  • Better separation of concerns in dependency resolution
  • Improved error messages for missing Firebase configuration

Code Quality:

  • Enhanced documentation and code comments
  • Better error handling and logging throughout
  • Improved initialization flow with proper state management

πŸ“š Documentation Updates #

Setup Guide Improvements:

  • Clearer instructions for Firebase initialization scenarios
  • Better error handling examples for missing configuration
  • Enhanced troubleshooting section

API Documentation:

  • Improved inline documentation for all public methods
  • Better examples of proper usage patterns
  • Clear separation between application-level and service-level responsibilities

πŸ› οΈ Migration Guide #

Breaking Changes in FirebaseCrashManager:

Before (v1.0.1):

// Old factory-based initialization
final crashManager = await FirebaseCrashManager.create();

After (v1.0.2):

// 1. Initialize Firebase in main.dart
await Firebase.initializeApp();

// 2. Create dependencies
final crashlytics = FirebaseCrashlytics.instance;
final logger = LogManagerFactory.createDefault();
final deviceManager = DeviceInfoManagerImpl();
final packageManager = PackageInfoManagerImpl();
final connectivityManager = await ConnectivityManagerFactory.createForProduction();

// 3. Inject dependencies
final crashManager = FirebaseCrashManager(
  crashlytics: crashlytics,
  logger: logger,
  deviceManager: deviceManager,
  packageManager: packageManager,
  connectivityManager: connectivityManager,
);

await crashManager.initialize();

Benefits of New Architecture:

  • Better testability with dependency injection
  • Clearer separation of concerns
  • Easier mocking for unit tests
  • More maintainable codebase
  • Firebase initialization handled at proper application level

πŸ› Bug Fixes #

  • Fixed potential initialization race conditions
  • Improved error handling for missing Firebase configuration
  • Better state management in crash manager lifecycle
  • Enhanced memory management with proper disposal

⚑ Performance Improvements #

  • Reduced initialization overhead with lazy loading
  • Better memory usage with improved object lifecycle management
  • More efficient error reporting with optimized data collection

1.0.1 - 2025-06-22 #

  • Fix linter problems
  • Add additional public API documentations

1.0.0 - 2025-06-22 #

πŸŽ‰ Initial Release #

Added

Core Features:

  • Complete crash reporting manager system with dependency inversion
  • Abstract CrashManager interface for unified crash reporting
  • Firebase Crashlytics implementation (FirebaseCrashManager)
  • Sentry implementation (SentryCrashManager)
  • Multi-service implementation (MultiCrashManager)

Data Models:

  • CrashReport - Comprehensive crash report model with all metadata
  • UserContext - User information and context for crashes
  • DeviceInfo - Device and app information collection
  • All models extend BaseDataModel from flutter_shared_utilities

Core Functionality:

  • Fatal and non-fatal crash reporting
  • Custom crash report creation and submission
  • User context management with authentication status
  • Device information collection across all platforms
  • Custom attributes and metadata support
  • Breadcrumb logging for debugging trails
  • Session management and tracking
  • Crash filtering with custom filter functions
  • Privacy controls with sensitive data sanitization

Utilities:

  • CrashUtils - Helper functions for crash management
    • Crash ID generation
    • Error message extraction
    • Stack trace truncation
    • Crash report formatting
    • Data sanitization
    • Crash deduplication
  • DeviceInfoCollector - Cross-platform device information
    • Android, iOS, macOS, Windows, Linux, Web support
    • Screen size, memory, connectivity information
    • App version and build information

Firebase Crashlytics Integration:

  • Complete Firebase Crashlytics SDK integration
  • Automatic Flutter error handling setup
  • Device context and user information syncing
  • Custom key and attribute support
  • Breadcrumb logging
  • Crash filtering
  • Pending reports management

Sentry Integration:

  • Full Sentry Flutter SDK integration
  • User context and device information
  • Custom tags and extra data
  • Breadcrumb support with levels
  • Scope management
  • Exception capturing with custom levels

Multi-Service Support:

  • Simultaneous use of multiple crash reporting services
  • Parallel operation execution for performance
  • Individual service error handling
  • Crash-free percentage aggregation
  • Safe operation execution with error isolation

Type Safety:

  • Comprehensive null safety throughout
  • Safe type conversion utilities
  • Proper error handling patterns
  • No force unwrapping or unsafe casting

Platform Support:

  • βœ… Android
  • βœ… iOS
  • βœ… macOS
  • βœ… Windows
  • βœ… Linux
  • βœ… Web

Dependencies

Core Dependencies:

  • flutter_shared_utilities: ^1.0.4 - Base data models and utilities
  • firebase_crashlytics: ^4.1.3 - Firebase Crashlytics SDK
  • firebase_core: ^3.6.0 - Firebase core functionality
  • sentry_flutter: ^8.9.0 - Sentry error tracking
  • logger: ^2.4.0 - Structured logging
  • connectivity_plus: ^6.0.5 - Network connectivity monitoring
  • device_info_plus: ^10.1.2 - Device information collection
  • package_info_plus: ^8.0.2 - App version information
  • dio: ^5.7.0 - HTTP client for API calls
  • shared_preferences: ^2.3.2 - Local storage

Development Dependencies:

  • flutter_test - Flutter testing framework
  • mockito: ^5.4.4 - Mocking for unit tests
  • build_runner: ^2.4.13 - Code generation
  • flutter_lints: ^5.0.0 - Flutter linting rules
  • custom_lint: ^0.7.5 - Custom linting
  • flutter_custom_lints: ^1.0.3 - Additional Flutter lints

Documentation

  • πŸ“– Comprehensive README with setup instructions
  • πŸ”§ Firebase Crashlytics setup guide for Android and iOS
  • πŸ”§ Sentry setup and configuration guide
  • πŸ’» Complete API documentation with examples
  • πŸ“ Best practices and usage patterns
  • πŸ› Troubleshooting guide for common issues
  • 🎯 Advanced usage examples with filtering and context

Examples

  • Basic crash manager setup
  • Firebase Crashlytics configuration
  • Sentry integration examples
  • Multi-service crash manager usage
  • Custom crash filtering implementation
  • Advanced context and metadata setup
  • Performance monitoring integration
  • Error boundary implementation

Technical Details #

Architecture

  • Clean Architecture principles with clear separation of concerns
  • Dependency inversion with abstract interfaces
  • Repository pattern for crash reporting services
  • Strategy pattern for multiple service support
  • Observer pattern for crash filtering

Performance

  • Asynchronous operations throughout
  • Parallel execution for multi-service operations
  • Efficient memory usage with proper disposal
  • Background processing for crash reporting
  • Rate limiting and throttling support

Security & Privacy

  • Built-in sensitive data sanitization
  • Configurable privacy controls
  • Secure token and credential handling
  • GDPR compliance considerations
  • User consent management support

Testing

  • Unit tests for all core functionality
  • Integration tests for service implementations
  • Mock implementations for testing
  • Test utilities for crash simulation
  • Comprehensive test coverage

Breaking Changes #

None - This is the initial release.

Migration Guide #

This is the initial release, no migration needed.

Known Issues #

  • None at this time

Deprecations #

  • None

[Unreleased] #

Planned Features #

  • Analytics integration for crash trends
  • Custom crash grouping algorithms
  • Real-time crash monitoring
  • Crash prediction and prevention
  • Enhanced performance monitoring
  • ML-based crash analysis
  • Custom dashboard integration
  • Webhook support for notifications
  • Advanced filtering with regex patterns
  • Crash impact scoring
  • User journey reconstruction
  • A/B testing integration for crash rates

Future Improvements #

  • Enhanced offline support
  • Custom encryption for sensitive data
  • Advanced sampling strategies
  • Custom reporting intervals
  • Batch processing optimization
  • Memory usage optimization
  • Battery usage monitoring
  • Network usage tracking
  • Custom crash categories
  • Enhanced debugging tools

Support & Feedback #

If you encounter any issues or have feature requests, please:

  1. Check the documentation first
  2. Search existing issues
  3. Create a new issue with detailed information
  4. Include crash manager version, Flutter version, and platform details

Contributing #

We welcome contributions! Please see our Contributing Guide for details on:

  • Code style and standards
  • Testing requirements
  • Pull request process
  • Development setup
  • Release process

License #

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