mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Ensure that flutter errors are also reported to sentry!
This commit is contained in:
parent
d0aa6a61ba
commit
c84941695d
@ -86,7 +86,7 @@ bool isInDebugMode() {
|
|||||||
|
|
||||||
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
||||||
|
|
||||||
print('Intercepted error: $error');
|
print('----- Sentry Intercepted error: $error -----');
|
||||||
print(stackTrace);
|
print(stackTrace);
|
||||||
|
|
||||||
// Errors thrown in development mode are unlikely to be interesting. You can
|
// Errors thrown in development mode are unlikely to be interesting. You can
|
||||||
@ -94,7 +94,7 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
|||||||
// the report.
|
// the report.
|
||||||
if (isInDebugMode()) {
|
if (isInDebugMode()) {
|
||||||
|
|
||||||
print('In dev mode. Not sending report to Sentry.io.');
|
print('----- In dev mode. Not sending report to Sentry.io -----');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,37 +12,32 @@ import 'package:one_context/one_context.dart';
|
|||||||
|
|
||||||
import 'dsn.dart';
|
import 'dsn.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
|
|
||||||
|
|
||||||
await Sentry.init((options) {
|
|
||||||
options.dsn = SENTRY_DSN_KEY;
|
|
||||||
},
|
|
||||||
//appRunner: () => runApp(InvenTreeApp())
|
|
||||||
);
|
|
||||||
|
|
||||||
await runZonedGuarded<Future<void>>(() async {
|
await runZonedGuarded<Future<void>>(() async {
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
await Sentry.init((options) {
|
||||||
|
options.dsn = SENTRY_DSN_KEY;
|
||||||
|
});
|
||||||
|
|
||||||
// This captures errors reported by the Flutter framework.
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
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());
|
// Pass any flutter errors off to the Sentry reporting context!
|
||||||
|
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||||
|
|
||||||
}, (Object error, StackTrace stackTrace) {
|
// Ensure that the error gets reported to sentry!
|
||||||
|
await sentryReportError(details.exception, details.stack);
|
||||||
|
};
|
||||||
|
|
||||||
|
runApp(
|
||||||
|
InvenTreeApp()
|
||||||
|
);
|
||||||
|
|
||||||
|
}, (Object error, StackTrace stackTrace) async {
|
||||||
sentryReportError(error, stackTrace);
|
sentryReportError(error, stackTrace);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,6 +76,7 @@ class InvenTreeApp extends StatelessWidget {
|
|||||||
const Locale('tr', ''),
|
const Locale('tr', ''),
|
||||||
const Locale('zh', ''),
|
const Locale('zh', ''),
|
||||||
],
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -432,7 +432,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
L10().stockItems,
|
L10().stockItems,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
subtitle: part.stockItems.isEmpty ? Text("No stock items available") : null,
|
subtitle: part.stockItems.isEmpty ? Text(L10().stockItemsNotAvailable) : null,
|
||||||
trailing: part.stockItems.isNotEmpty ? Text("${part.stockItems.length}") : null,
|
trailing: part.stockItems.isNotEmpty ? Text("${part.stockItems.length}") : null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -463,7 +463,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Scan New Stock Item"),
|
title: Text(L10().barcodeScanItem),
|
||||||
leading: FaIcon(FontAwesomeIcons.box),
|
leading: FaIcon(FontAwesomeIcons.box),
|
||||||
trailing: FaIcon(FontAwesomeIcons.qrcode),
|
trailing: FaIcon(FontAwesomeIcons.qrcode),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user