Developer
Observability
A Flutter package designed to log and report errors to any supported crash reporting tool. It comes with built-in support for several popular providers, and you can easily integrate additional crash reporting tools by implementing a simple interface.
Features
- Unified Interface: A common interface that allows seamless integration with various crash reporting tools.
- Firebase Crashlytics Integration: Use Firebase Crashlytics for error logging via the
eit_service_crash_firebase
package. - AppGallery Crash Integration: Report crashes to Huawei’s AppGallery using the
eit_service_crash_huawei
package.
Installation
dart pub add eit_crash_service --hosted-url=https://gitea.whitelabel.mobile.embedit.dev/api/packages/platform/pub/
!IMPORTANT You need access token for fetching from private pub repository. ELI add token automatically
Usage
final EitCrashService service = EitFirebaseCrashService(); // or EitHuaweiCrashService()
/// Reports a message.
await service.log('Some message');
/// Records a user ID (identifier) that's associated with reports.
await service.setUserId(userId: 'user1');
/// Sets a custom key and value that are associated with subsequent reports.
await setCustomKey(key: 'key', value: 'value');
/// Reports an exception.
await recordError(exception, stackTrace);
/// Reports a Flutter error
await recordFlutterError(flutterErrorDetails);
/// Reports a Flutter fatal error
await recordFlutterFatalError(flutterErrorDetails);
/// Submits a testing Crash report
await testCrash();
Flutter
To report Flutter errors to a crash reporting tool, follow the guidelines outlined in Handling errors in Flutter.
Future<void> main() async {
final EitCrashService service = EitFirebaseCrashService(); // or EitHuaweiCrashService()
FlutterError.onError = (details) {
FlutterError.presentError(details);
service.recordFlutterError(details);
};
PlatformDispatcher.instance.onError = (error, stack) {
service.recordError(error, stack);
return true;
};
runApp(const MyApp());
}