Skip to content

Commit

Permalink
Merge pull request #9 from solutelabs/replace_sentry_with_crashlytics
Browse files Browse the repository at this point in the history
Replace Sentry with Crashlytics
  • Loading branch information
Milind Mevada authored Jun 12, 2020
2 parents b2cd6ac + 9922875 commit c333e52
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 78 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Modes: Debug, Release, Profile.
### Localization
Localization support based on [Easy Localization](https://pub.dev/packages/easy_localization)

### Custom Logger (Default Sentry)
Abstract layer for a custom logger. It has default implementation of [Sentry](https://sentry.io/welcome/).
### Custom Logger (Default Crashlytics)
Abstract layer for a custom logger. It has default implementation of [Crashlytics](https://firebase.google.com/products/crashlytics/).
It can again be replaced with any other services.

### Firebase Crashalytics
Expand Down
9 changes: 9 additions & 0 deletions lib/src/error_logger/crashlytics_error_logger.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter_base_project/src/error_logger/error_logger.dart';

class CrashlyticsErrorLogger implements ErrorLogger {
@override
Future<void> logEvent({dynamic exception, StackTrace stackTrace}) async {
Crashlytics.instance.recordError(exception, stackTrace);
}
}
38 changes: 2 additions & 36 deletions lib/src/error_logger/error_logger.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'package:device_info/device_info.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_base_project/src/error_logger/sentry_error_logger.dart';
import 'package:package_info/package_info.dart';
import 'package:flutter_base_project/src/error_logger/crashlytics_error_logger.dart';

abstract class ErrorLogger {
Future<void> logEvent({
Expand All @@ -10,37 +7,6 @@ abstract class ErrorLogger {
});
}

Future<Map<String, String>> tags() async {
final info = await PackageInfo.fromPlatform();
return {
"platform": defaultTargetPlatform.toString(),
"package_name": info.packageName,
"build_number": info.buildNumber,
"version": info.version,
};
}

Future<Map<String, dynamic>> extras() async {
final deviceInfo = DeviceInfoPlugin();
final Map<String, dynamic> extras = {};
if (defaultTargetPlatform == TargetPlatform.android) {
final info = await deviceInfo.androidInfo;
extras['device_info'] = {
"model": info.model,
"brand": info.brand,
"manufacturer": info.manufacturer,
"version": info.version.release,
};
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
final info = await deviceInfo.iosInfo;
extras['device_info'] = {
"model": info.model,
"version": info.systemVersion,
};
}
return extras;
}

ErrorLogger getErrorLogger() {
return SentryErrorLogger();
return CrashlyticsErrorLogger();
}
38 changes: 0 additions & 38 deletions lib/src/error_logger/sentry_error_logger.dart

This file was deleted.

2 changes: 0 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ dependencies:

package_info: ^0.4.0+16

sentry: ^3.0.1

url_launcher: ^5.4.2

#Firebase
Expand Down

0 comments on commit c333e52

Please sign in to comment.