From 59585f72cf9ab46d08e8ba8277ac145d58c3c1a6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 16 Feb 2021 08:03:01 +1100 Subject: [PATCH] Remove all sentry references - Google play store already offers crash reporting... --- .gitignore | 3 - ios/Flutter/flutter_export_environment.sh | 2 +- lib/api.dart | 2 +- lib/inventree/model.dart | 8 +- lib/inventree/sentry.dart | 168 ---------------------- lib/inventree/stock.dart | 2 +- lib/main.dart | 35 ----- lib/settings/settings.dart | 49 ------- pubspec.lock | 14 -- pubspec.yaml | 3 +- 10 files changed, 8 insertions(+), 278 deletions(-) delete mode 100644 lib/inventree/sentry.dart diff --git a/.gitignore b/.gitignore index c8c53d7a..da53ba0b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,6 @@ .history .svn/ -# Sentry API key -lib/dsn.dart - # App signing key android/key.properties diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index d36a6600..0621fdd1 100644 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -8,7 +8,7 @@ export "SYMROOT=${SOURCE_ROOT}/../build\ios" export "OTHER_LDFLAGS=$(inherited) -framework Flutter" export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios" export "FLUTTER_BUILD_NAME=0.1.0" -export "FLUTTER_BUILD_NUMBER=0.1.0" +export "FLUTTER_BUILD_NUMBER=3" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=false" export "TREE_SHAKE_ICONS=false" diff --git a/lib/api.dart b/lib/api.dart index 127152f0..1730a444 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -211,7 +211,7 @@ class InvenTreeAPI { showTimeoutError(context); return null; } else { - // Unknown error type - re-throw the error and Sentry will catch it + // Unknown error type - re-throw throw error; } }); diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index ee2d58d6..16633f59 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -156,7 +156,7 @@ class InvenTreeModel { else if (e is TimeoutException) { showTimeoutError(context); } else { - // Re-throw the error (Sentry will catch) + // Re-throw the error throw e; } @@ -202,7 +202,7 @@ class InvenTreeModel { } else if (e is TimeoutException) { showTimeoutError(context); } else { - // Re-throw the error, let Sentry report it + // Re-throw the error throw e; } @@ -253,7 +253,7 @@ class InvenTreeModel { else if (e is TimeoutException) { showTimeoutError(context); } else { - // Re-throw the error (handled by Sentry) + // Re-throw the error throw e; } return null; @@ -301,7 +301,7 @@ class InvenTreeModel { else if (e is TimeoutException) { showTimeoutError(context); } else { - // Re-throw the error (Sentry will catch) + // Re-throw the error throw e; } diff --git a/lib/inventree/sentry.dart b/lib/inventree/sentry.dart deleted file mode 100644 index 1e242e03..00000000 --- a/lib/inventree/sentry.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'dart:io'; - -import 'package:device_info/device_info.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:package_info/package_info.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; -import 'package:one_context/one_context.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - -import '../api.dart'; - -Future> getDeviceInfo() async { - - // Extract device information - final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - - Map device_info = {}; - - // Extract some platform information - if (Platform.isIOS) { - final iosDeviceInfo = await deviceInfo.iosInfo; - - device_info = { - 'name': iosDeviceInfo.name, - 'model': iosDeviceInfo.model, - 'systemName': iosDeviceInfo.systemName, - 'systemVersion': iosDeviceInfo.systemVersion, - 'localizedModel': iosDeviceInfo.localizedModel, - 'utsname': iosDeviceInfo.utsname.sysname, - 'identifierForVendor': iosDeviceInfo.identifierForVendor, - 'isPhysicalDevice': iosDeviceInfo.isPhysicalDevice, - }; - - } else if (Platform.isAndroid) { - final androidDeviceInfo = await deviceInfo.androidInfo; - - device_info = { - 'type': androidDeviceInfo.type, - 'model': androidDeviceInfo.model, - 'device': androidDeviceInfo.device, - 'id': androidDeviceInfo.id, - 'androidId': androidDeviceInfo.androidId, - 'brand': androidDeviceInfo.brand, - 'display': androidDeviceInfo.display, - 'hardware': androidDeviceInfo.hardware, - 'manufacturer': androidDeviceInfo.manufacturer, - 'product': androidDeviceInfo.product, - 'version': androidDeviceInfo.version.release, - 'supported32BitAbis': androidDeviceInfo.supported32BitAbis, - 'supported64BitAbis': androidDeviceInfo.supported64BitAbis, - 'supportedAbis': androidDeviceInfo.supportedAbis, - 'isPhysicalDevice': androidDeviceInfo.isPhysicalDevice, - }; - } - - return device_info; -} - - -Map getServerInfo() => { - "version": InvenTreeAPI().version, -}; - - -Future> getAppInfo() async { - // Add app info - final package_info = await PackageInfo.fromPlatform(); - - return { - "name": package_info.appName, - "build": package_info.buildNumber, - "version": package_info.version, - "package": package_info.packageName, - }; -} - - -bool isInDebugMode() { - bool inDebugMode = false; - - assert(inDebugMode = true); - - return inDebugMode; -} - -Future _uploadErrorReport(dynamic error, dynamic stackTrace) async { - - // Errors thrown in development mode are unlikely to be interesting. You can - // check if you are running in dev mode using an assertion and omit sending - // the report. - if (isInDebugMode()) { - - print('In dev mode. Not sending report to Sentry.io.'); - return; - } - - final server_info = getServerInfo(); - final app_info = await getAppInfo(); - final device_info = await getDeviceInfo(); - - Sentry.configureScope((scope) { - scope.setExtra("server", server_info); - scope.setExtra("app", app_info); - scope.setExtra("device", device_info); - }); - - Sentry.captureException(error, stackTrace: stackTrace).catchError((error) { - print("Error uploading information to Sentry.io:"); - print(error); - }).then((response) { - print("Uploaded information to Sentry.io : ${response.toString()}"); - }); -} - - -Future sentryReportError(dynamic error, dynamic stackTrace) async { - - print('Intercepted error: $error'); - print(stackTrace); - - await OneContext().showDialog( - builder: (context) => AlertDialog( - title: ListTile( - title: Text(I18N.of(OneContext().context).error), - leading: FaIcon(FontAwesomeIcons.exclamationCircle), - subtitle: Text("An error occurred"), - ), - actions: [ - FlatButton( - child: Text("Upload Error Report"), - onPressed: () { - _uploadErrorReport(error, stackTrace); - OneContext().pop(); - }, - ) - ], - content: Text(error.toString()), - ) - ); - - return; - -} - - -Future sentryReportMessage(String message) async { - - final server_info = getServerInfo(); - final app_info = await getAppInfo(); - final device_info = await getDeviceInfo(); - - print("Sending user message to Sentry"); - - Sentry.configureScope((scope) { - scope.setExtra("server", server_info); - scope.setExtra("app", app_info); - scope.setExtra("device", device_info); - }); - - final sentryId = await Sentry.captureMessage(message).catchError((error) { - print("Error uploading sentry messages..."); - print(error); - return null; - }); - - return sentryId != null; -} \ No newline at end of file diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 4dd212f0..fea031f5 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -447,7 +447,7 @@ class InvenTreeStockItem extends InvenTreeModel { error.toString() ); } else { - // Re-throw the error, let sentry handle it! + // Re-throw the error throw error; } diff --git a/lib/main.dart b/lib/main.dart index c27bef8c..e647af8f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,3 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:InvenTree/inventree/sentry.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -10,42 +6,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:one_context/one_context.dart'; -import 'dsn.dart'; - -import 'package:sentry_flutter/sentry_flutter.dart'; - - void main() async { - - await Sentry.init((options) { - options.dsn = SENTRY_DSN_KEY; - }, - //appRunner: () => runApp(InvenTreeApp()) - ); - - await runZonedGuarded>(() async { - WidgetsFlutterBinding.ensureInitialized(); - // This captures errors reported by the Flutter framework. - FlutterError.onError = (FlutterErrorDetails details) async { - if (isInDebugMode()) { - // In development mode simply print to console. - FlutterError.dumpErrorToConsole(details); - } else { - // In production mode report to the application zone to report to - // Sentry. - Zone.current.handleUncaughtError(details.exception, details.stack); - } - }; - runApp(InvenTreeApp()); - - }, (Object error, StackTrace stackTrace) { - sentryReportError(error, stackTrace); - }); - } class InvenTreeApp extends StatelessWidget { diff --git a/lib/settings/settings.dart b/lib/settings/settings.dart index a2183781..304540ed 100644 --- a/lib/settings/settings.dart +++ b/lib/settings/settings.dart @@ -1,14 +1,9 @@ -import 'package:InvenTree/inventree/sentry.dart'; import 'package:InvenTree/settings/about.dart'; import 'package:InvenTree/settings/login.dart'; import 'package:InvenTree/user_profile.dart'; -import 'package:InvenTree/widget/dialogs.dart'; -import 'package:InvenTree/widget/snacks.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -28,7 +23,6 @@ class InvenTreeSettingsWidget extends StatefulWidget { class _InvenTreeSettingsState extends State { final _scaffoldKey = GlobalKey(); - final _bugKey = GlobalKey(); final String docsUrl = "https://inventree.readthedocs.io/en/latest/app/app/"; @@ -66,12 +60,6 @@ class _InvenTreeSettingsState extends State { }, ), - ListTile( - title: Text(I18N.of(context).reportBug), - subtitle: Text("Report bug or suggest new feature"), - leading: FaIcon(FontAwesomeIcons.bug), - onTap: _reportBug, - ), ] ).toList() ) @@ -100,41 +88,4 @@ class _InvenTreeSettingsState extends State { MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info))); }); } - - void _sendReport(String message) async { - - bool result = await sentryReportMessage(message); - - if (result) { - showSnackIcon(_scaffoldKey, "Uploaded report", success: true); - } else { - showSnackIcon(_scaffoldKey, "Report upload failed", success: false); - } - } - - void _reportBug() async { - - TextEditingController _controller = TextEditingController(); - - _controller.clear(); - - showFormDialog( - "Upload Bug Report", - key: _bugKey, - callback: () { - _sendReport(_controller.text); - }, - fields: [ - TextField( - decoration: InputDecoration( - hintText: "Enter bug report details", - ), - keyboardType: TextInputType.multiline, - maxLines: null, - controller: _controller - ), - ] - ); - - } } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 2e7d0cd4..f7db14b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -427,20 +427,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.9" - sentry: - dependency: transitive - description: - name: sentry - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.4" - sentry_flutter: - dependency: "direct main" - description: - name: sentry_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.4" shared_preferences: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 330582a0..04287523 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ description: InvenTree stock management # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.1.0+2 +version: 0.1.0+3 environment: sdk: ">=2.1.0 <3.0.0" @@ -29,7 +29,6 @@ dependencies: device_info: ^1.0.0 # Information about the device font_awesome_flutter: ^8.8.1 # FontAwesome icon set flutter_speed_dial: ^1.2.5 # FAB menu elements - sentry_flutter: ^4.0.4 # Error reporting flutter_typeahead: ^1.8.1 # Auto-complete input field image_picker: ^0.6.6 # Select or take photos url_launcher: ^5.7.10 # Open link in system browser