From 7b35604ff586ecd7d040a5a941bdd60aa6f5827f Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 20 Feb 2023 22:17:41 +0200 Subject: [PATCH 1/9] Add app version and device info to error report --- android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- cw_haven/pubspec.yaml | 2 +- cw_monero/pubspec.yaml | 2 +- lib/utils/exception_handler.dart | 88 ++++++++++++++++++- 5 files changed, 90 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 04c2af566..692e8dfb1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.5.10' + ext.kotlin_version = '1.6.21' repositories { google() jcenter() diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index b7ca2e6de..733c691d3 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/cw_haven/pubspec.yaml b/cw_haven/pubspec.yaml index 28f2c315e..7a5ac6aa4 100644 --- a/cw_haven/pubspec.yaml +++ b/cw_haven/pubspec.yaml @@ -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 diff --git a/cw_monero/pubspec.yaml b/cw_monero/pubspec.yaml index 23e8782cb..6d5041dfa 100644 --- a/cw_monero/pubspec.yaml +++ b/cw_monero/pubspec.yaml @@ -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 diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 4cbebdb5d..8aefe7bc6 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -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'], @@ -130,4 +133,85 @@ class ExceptionHandler { "errno = 28", // OS Error: No space left on device "PERMISSION_NOT_GRANTED", ]; + + static Future _addDeviceInfo(File file) async { + final packageInfo = await PackageInfo.fromPlatform(); + final currentVersion = packageInfo.version; + + final deviceInfoPlugin = DeviceInfoPlugin(); + Map 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 _readAndroidBuildData(AndroidDeviceInfo build) { + return { + 'brand': build.brand, + 'device': build.device, + 'manufacturer': build.manufacturer, + 'model': build.model, + 'product': build.product, + }; + } + + static Map _readIosDeviceInfo(IosDeviceInfo data) { + return { + 'systemName': data.systemName, + 'systemVersion': data.systemVersion, + 'model': data.model, + 'localizedModel': data.localizedModel, + }; + } + + static Map _readLinuxDeviceInfo(LinuxDeviceInfo data) { + return { + '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 _readMacOsDeviceInfo(MacOsDeviceInfo data) { + return { + 'arch': data.arch, + 'model': data.model, + 'kernelVersion': data.kernelVersion, + 'osRelease': data.osRelease, + }; + } + + static Map _readWindowsDeviceInfo(WindowsDeviceInfo data) { + return { + 'majorVersion': data.majorVersion, + 'minorVersion': data.minorVersion, + 'buildNumber': data.buildNumber, + 'productType': data.productType, + 'productName': data.productName, + }; + } } From 37ea2d341f2a305265b0dc21b92cbc110fdb41eb Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 20 Feb 2023 22:25:54 +0200 Subject: [PATCH 2/9] Add Exception handler to report loading wallet issues --- lib/reactions/on_authentication_state_change.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/reactions/on_authentication_state_change.dart b/lib/reactions/on_authentication_state_change.dart index edadf33b0..7521170e6 100644 --- a/lib/reactions/on_authentication_state_change.dart +++ b/lib/reactions/on_authentication_state_change.dart @@ -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; } From d589e72ae8a618a49af57afa131ccfc82b48b013 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 21 Feb 2023 00:03:57 +0200 Subject: [PATCH 3/9] update file picker version --- pubspec_base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec_base.yaml b/pubspec_base.yaml index 2caa9052f..6086d698a 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -55,7 +55,7 @@ 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 From 38b7a2ff45aec1767b4c5d9b9aea7209cddf20f9 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 21 Feb 2023 01:28:30 +0200 Subject: [PATCH 4/9] Add device info dependency to pubspec_base.yaml --- pubspec_base.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec_base.yaml b/pubspec_base.yaml index 6086d698a..079ba7c76 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -62,6 +62,7 @@ dependencies: 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 From db1fdac2b50e752ea81d16dfdf0a0f8ef74f17c0 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 22 Feb 2023 04:15:18 +0200 Subject: [PATCH 5/9] Add connection timed out error to ignored exceptions [skip ci] --- lib/utils/exception_handler.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 8aefe7bc6..55d27e6a1 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -128,6 +128,7 @@ class ExceptionHandler { "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 From 9c26912ce948d4cad6734bdfa8e849a97f0a76ca Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 27 Feb 2023 18:28:30 +0200 Subject: [PATCH 6/9] Add Socket exception to ignored errors [skip ci] --- lib/utils/exception_handler.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 55d27e6a1..8285b9c52 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -131,6 +131,7 @@ class ExceptionHandler { "errno = 110", // SocketException: Connection timed out "errno = 54", // SocketException: Connection reset by peer "errno = 49", // SocketException: Can't assign requested address + "errno = 57", // SocketException: Read failed (OS Error: Socket is not connected) "errno = 28", // OS Error: No space left on device "PERMISSION_NOT_GRANTED", ]; From 25ec44b4e515b1628ee53db2fd2dda744f8b66ac Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 28 Feb 2023 15:37:20 +0200 Subject: [PATCH 7/9] Add missing Nano currency image [skip ci] --- cw_core/lib/crypto_currency.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cw_core/lib/crypto_currency.dart b/cw_core/lib/crypto_currency.dart index 90051f1f7..00bfc237c 100644 --- a/cw_core/lib/crypto_currency.dart +++ b/cw_core/lib/crypto_currency.dart @@ -94,7 +94,7 @@ class CryptoCurrency extends EnumerableItem with Serializable { 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'); From ee67bc76d716c07cb91420f3f1194bcf8339ea4d Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 28 Feb 2023 16:18:06 +0200 Subject: [PATCH 8/9] Fix translation issue --- res/values/strings_bg.arb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings_bg.arb b/res/values/strings_bg.arb index 32e9ed0c5..2099abc19 100644 --- a/res/values/strings_bg.arb +++ b/res/values/strings_bg.arb @@ -327,7 +327,7 @@ "error_text_fiat" : "Сумата не може да надвишава наличния баланс.\nThe number of fraction digits must be less or equal to 2", "error_text_subaddress_name" : "Името на подадреса не може да съдържат символите ` , ' \" \n и трябва да е между 1 и 20 символа", "error_text_amount" : "Сумата може да съдържа само числа", - "error_text_wallet_name" : "Името на портфейла може да съдържа само букви, цифри, и символите "_" и "-" \n и трябва да е между 1 и 33 символа", + "error_text_wallet_name" : "Името на портфейла може да съдържа само букви, цифри, и символите _ и - \n и трябва да е между 1 и 33 символа", "error_text_keys" : "Ключовете за портфейл може да съдържат само 64 шестнайсетични символа", "error_text_crypto_currency" : "Броят на цифрите след десетичната запетая\nможе да бъде най-много 12", "error_text_minimal_limit" : "Сделка за ${provider} не беше създадена. Сумата е по-малко от минималната: ${min} ${currency}", From 247ec24e46693d3248d9a0e69d89a5aaf28020e2 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 1 Mar 2023 15:47:16 +0200 Subject: [PATCH 9/9] Re-organize ignored errors in ascending order of errno [skip ci] --- lib/utils/exception_handler.dart | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 8285b9c52..51a525394 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -124,15 +124,16 @@ class ExceptionHandler { _ignoredErrors.any((element) => error.contains(element)); static const List _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 = 57", // SocketException: Read failed (OS Error: Socket is not connected) "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", ];