Merge pull request #794 from cake-tech/error-report-enhancements

Error Reports Enhancements
This commit is contained in:
Omar Hatem 2023-03-02 21:39:43 +02:00 committed by GitHub
commit 960f761c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 16 deletions

View file

@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

View file

@ -94,7 +94,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
static const eos = CryptoCurrency(title: 'EOS', fullName: 'EOS', raw: 7, name: 'eos', iconPath: 'assets/images/eos_icon.png');
static const eth = CryptoCurrency(title: 'ETH', fullName: 'Ethereum', raw: 8, name: 'eth', iconPath: 'assets/images/eth_icon.png');
static const ltc = CryptoCurrency(title: 'LTC', fullName: 'Litecoin', raw: 9, name: 'ltc', iconPath: 'assets/images/litecoin-ltc_icon.png');
static const nano = CryptoCurrency(title: 'NANO', raw: 10, name: 'nano');
static const nano = CryptoCurrency(title: 'NANO', raw: 10, name: 'nano', iconPath: 'assets/images/nano.png');
static const trx = CryptoCurrency(title: 'TRX', fullName: 'TRON', raw: 11, name: 'trx', iconPath: 'assets/images/trx_icon.png');
static const usdt = CryptoCurrency(title: 'USDT', tag: 'OMNI', fullName: 'USDT Tether', raw: 12, name: 'usdt', iconPath: 'assets/images/usdt_icon.png');
static const usdterc20 = CryptoCurrency(title: 'USDT', tag: 'ETH', fullName: 'USDT Tether', raw: 13, name: 'usdterc20', iconPath: 'assets/images/usdterc20_icon.png');

View file

@ -12,7 +12,7 @@ environment:
dependencies:
flutter:
sdk: flutter
ffi: ^1.1.2
ffi: ^2.0.1
http: ^0.13.4
path_provider: ^2.0.11
mobx: ^2.0.7+4

View file

@ -12,7 +12,7 @@ environment:
dependencies:
flutter:
sdk: flutter
ffi: ^1.1.2
ffi: ^2.0.1
http: ^0.13.4
path_provider: ^2.0.11
mobx: ^2.0.7+4

View file

@ -1,4 +1,5 @@
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:flutter/widgets.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/entities/load_current_wallet.dart';
@ -16,8 +17,9 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
if (state == AuthenticationState.installed) {
try {
await loadCurrentWallet();
} catch (e) {
loginError = e;
} catch (error, stack) {
loginError = error;
ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stack));
}
return;
}

View file

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';
import 'package:cake_wallet/entities/preferences_key.dart';
@ -6,9 +5,11 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/main.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mailer/flutter_mailer.dart';
import 'package:package_info/package_info.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -31,7 +32,7 @@ class ExceptionHandler {
==========================================================\n\n''';
await file.writeAsString(
jsonEncode(exception) + separator,
"$exception $separator",
mode: FileMode.append,
);
}
@ -42,6 +43,8 @@ class ExceptionHandler {
final file = File('${appDocDir.path}/error.txt');
await _addDeviceInfo(file);
final MailOptions mailOptions = MailOptions(
subject: 'Mobile App Issue',
recipients: ['support@cakewallet.com'],
@ -121,14 +124,97 @@ class ExceptionHandler {
_ignoredErrors.any((element) => error.contains(element));
static const List<String> _ignoredErrors = const [
"errno = 103", // SocketException: Software caused connection abort
"errno = 9", // SocketException: Bad file descriptor
"errno = 32", // SocketException: Write failed (OS Error: Broken pipe)
"errno = 60", // SocketException: Operation timed out
"errno = 110", // SocketException: Connection timed out
"errno = 54", // SocketException: Connection reset by peer
"errno = 49", // SocketException: Can't assign requested address
"errno = 28", // OS Error: No space left on device
"errno = 32", // SocketException: Write failed (OS Error: Broken pipe)
"errno = 49", // SocketException: Can't assign requested address
"errno = 54", // SocketException: Connection reset by peer
"errno = 57", // SocketException: Read failed (OS Error: Socket is not connected)
"errno = 60", // SocketException: Operation timed out
"errno = 103", // SocketException: Software caused connection abort
"errno = 104", // SocketException: Connection reset by peer
"errno = 110", // SocketException: Connection timed out
"PERMISSION_NOT_GRANTED",
];
static Future<void> _addDeviceInfo(File file) async {
final packageInfo = await PackageInfo.fromPlatform();
final currentVersion = packageInfo.version;
final deviceInfoPlugin = DeviceInfoPlugin();
Map<String, dynamic> deviceInfo = {};
if (Platform.isAndroid) {
deviceInfo = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);
deviceInfo["Platform"] = "Android";
} else if (Platform.isIOS) {
deviceInfo = _readIosDeviceInfo(await deviceInfoPlugin.iosInfo);
deviceInfo["Platform"] = "iOS";
} else if (Platform.isLinux) {
deviceInfo = _readLinuxDeviceInfo(await deviceInfoPlugin.linuxInfo);
deviceInfo["Platform"] = "Linux";
} else if (Platform.isMacOS) {
deviceInfo = _readMacOsDeviceInfo(await deviceInfoPlugin.macOsInfo);
deviceInfo["Platform"] = "MacOS";
} else if (Platform.isWindows) {
deviceInfo = _readWindowsDeviceInfo(await deviceInfoPlugin.windowsInfo);
deviceInfo["Platform"] = "Windows";
}
await file.writeAsString(
"App Version: $currentVersion\n\nDevice Info $deviceInfo",
mode: FileMode.append,
);
}
static Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
return <String, dynamic>{
'brand': build.brand,
'device': build.device,
'manufacturer': build.manufacturer,
'model': build.model,
'product': build.product,
};
}
static Map<String, dynamic> _readIosDeviceInfo(IosDeviceInfo data) {
return <String, dynamic>{
'systemName': data.systemName,
'systemVersion': data.systemVersion,
'model': data.model,
'localizedModel': data.localizedModel,
};
}
static Map<String, dynamic> _readLinuxDeviceInfo(LinuxDeviceInfo data) {
return <String, dynamic>{
'name': data.name,
'version': data.version,
'versionCodename': data.versionCodename,
'versionId': data.versionId,
'prettyName': data.prettyName,
'buildId': data.buildId,
'variant': data.variant,
'variantId': data.variantId,
};
}
static Map<String, dynamic> _readMacOsDeviceInfo(MacOsDeviceInfo data) {
return <String, dynamic>{
'arch': data.arch,
'model': data.model,
'kernelVersion': data.kernelVersion,
'osRelease': data.osRelease,
};
}
static Map<String, dynamic> _readWindowsDeviceInfo(WindowsDeviceInfo data) {
return <String, dynamic>{
'majorVersion': data.majorVersion,
'minorVersion': data.minorVersion,
'buildNumber': data.buildNumber,
'productType': data.productType,
'productName': data.productName,
};
}
}

View file

@ -55,13 +55,14 @@ dependencies:
another_flushbar: ^1.12.29
archive: ^3.3.0
cryptography: ^2.0.5
file_picker: ^4.6.1
file_picker: ^5.2.5
unorm_dart: ^0.2.0
# check unorm_dart for usage and for replace
permission_handler: ^10.0.0
device_display_brightness: ^0.0.6
platform_device_id: ^1.0.1
flutter_mailer: ^2.0.2
device_info_plus: ^8.1.0
cake_backup:
git:
url: https://github.com/cake-tech/cake_backup.git