diff --git a/lib/mainCommon.dart b/lib/mainCommon.dart index 314d78d..919ae3b 100644 --- a/lib/mainCommon.dart +++ b/lib/mainCommon.dart @@ -5,9 +5,11 @@ import 'package:fires_flutter/models/yourLocationPersist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_simple_dependency_injection/injector.dart'; import 'package:redux/redux.dart'; +import 'package:sentry/sentry.dart'; import 'firebaseMessagingConf.dart'; import 'firesApp.dart'; +import 'globals.dart' as globals; import 'models/appState.dart'; import 'models/firesApi.dart'; import 'redux/fetchDataMiddleware.dart'; @@ -33,12 +35,20 @@ void mainCommon(List> otherMiddleware) { injector.map(String, (i) => store.state.firesApiKey, key: "firesApiKey"); injector.map(String, (i) => store.state.gmapKey, key: "gmapKey"); - loadYourLocations().then((yl) { - firebaseConfig(store); + VoidCallback mainFn = () { + loadYourLocations().then((yl) { + firebaseConfig(store); - // Run baby run! - runApp(new FiresApp(store)); - }); + // Run baby run! + runApp(new FiresApp(store)); + }); + }; + + if (!globals.isDevelopment) + // Run in production with sentry catch + main(mainFn, secrets['sentryDSN']); + else + mainFn(); // Listen to store changes, and re-render when the state is updated store.onChange.listen((state) { @@ -46,3 +56,14 @@ void mainCommon(List> otherMiddleware) { }); }); } + +main(mainFn, key) async { + SentryClient sentry = new SentryClient(dsn: key); + mainFn(); + try {} catch (error, stackTrace) { + await sentry.captureException( + exception: error, + stackTrace: stackTrace, + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 6c57ce3..8d36f52 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: simple_moment: "^0.0.3" just_debounce_it: "^1.0.4" flutter_simple_dependency_injection: "^0.0.2" + sentry: "^2.0.2" # net http: "^0.11.3+16"