Add sentry
This commit is contained in:
parent
aba66b70b1
commit
a7ddad3baf
|
|
@ -4,4 +4,5 @@ class Config {
|
|||
static const String LOGIN_URL = 'http://www.ninja.test';
|
||||
static const String LOGIN_SECRET = 'secret';
|
||||
static const String API_SECRET = 'secret';
|
||||
static const String SENTRY_DNS = '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:invoiceninja_flutter/.env.dart';
|
||||
import 'package:sentry/sentry.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company/company_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
||||
import 'package:invoiceninja_flutter/ui/invoice/invoice_email_vm.dart';
|
||||
|
|
@ -37,27 +41,24 @@ import 'package:invoiceninja_flutter/redux/invoice/invoice_middleware.dart';
|
|||
import 'package:invoiceninja_flutter/ui/invoice/invoice_screen.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
//import 'package:quick_actions/quick_actions.dart';
|
||||
|
||||
//import 'package:quick_actions/quick_actions.dart';
|
||||
// STARTER: import - do not remove comment
|
||||
import 'package:invoiceninja_flutter/ui/task/task_screen.dart';
|
||||
import 'package:invoiceninja_flutter/ui/task/edit/task_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/task/view/task_view_vm.dart';
|
||||
import 'package:invoiceninja_flutter/redux/task/task_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/task/task_middleware.dart';
|
||||
|
||||
import 'package:invoiceninja_flutter/ui/project/project_screen.dart';
|
||||
import 'package:invoiceninja_flutter/ui/project/edit/project_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/project/view/project_view_vm.dart';
|
||||
import 'package:invoiceninja_flutter/redux/project/project_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/project/project_middleware.dart';
|
||||
|
||||
import 'package:invoiceninja_flutter/ui/payment/payment_screen.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/edit/payment_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/view/payment_view_vm.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment/payment_middleware.dart';
|
||||
|
||||
import 'package:invoiceninja_flutter/ui/quote/quote_screen.dart';
|
||||
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/quote/view/quote_view_vm.dart';
|
||||
|
|
@ -65,10 +66,12 @@ import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
|||
import 'package:invoiceninja_flutter/redux/quote/quote_middleware.dart';
|
||||
|
||||
void main() async {
|
||||
final SentryClient _sentry = SentryClient(dsn: Config.SENTRY_DNS);
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false;
|
||||
final requireAuthentication =
|
||||
prefs.getBool(kSharedPrefRequireAuthentication) ?? false;
|
||||
|
||||
final store = Store<AppState>(appReducer,
|
||||
initialState: AppState(
|
||||
enableDarkMode: enableDarkMode,
|
||||
|
|
@ -89,7 +92,38 @@ void main() async {
|
|||
LoggingMiddleware<dynamic>.printer(),
|
||||
]));
|
||||
|
||||
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
||||
print('Caught error: $error');
|
||||
if (isInDebugMode) {
|
||||
print(stackTrace);
|
||||
return;
|
||||
} else {
|
||||
_sentry.captureException(
|
||||
exception: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
runZoned<Future<void>>(() async {
|
||||
runApp(InvoiceNinjaApp(store: store));
|
||||
}, onError: (dynamic error, dynamic stackTrace) {
|
||||
_reportError(error, stackTrace);
|
||||
});
|
||||
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
if (isInDebugMode) {
|
||||
FlutterError.dumpErrorToConsole(details);
|
||||
} else {
|
||||
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool get isInDebugMode {
|
||||
bool inDebugMode = false;
|
||||
assert(inDebugMode = true);
|
||||
return inDebugMode;
|
||||
}
|
||||
|
||||
class InvoiceNinjaApp extends StatefulWidget {
|
||||
|
|
|
|||
14
pubspec.lock
14
pubspec.lock
|
|
@ -495,6 +495,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
sentry:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sentry
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
share:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -654,6 +661,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
usage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: usage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.4.1"
|
||||
utf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ dependencies:
|
|||
google_sign_in: ^3.2.4
|
||||
firebase_auth: ^0.6.2+1
|
||||
local_auth: ^0.3.0
|
||||
sentry: ^2.2.0
|
||||
#quick_actions: ^0.2.1
|
||||
#flutter_html_view: ^0.5.8
|
||||
#flutter_html: ^0.5.3
|
||||
|
|
|
|||
Loading…
Reference in New Issue