2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-16 12:15:31 +00:00

Sentry fix (#395)

* Extra sentry diagnostics

* Fix unit test

* Unit test updates

* More unit test updates
This commit is contained in:
Oliver
2023-07-07 21:38:04 +10:00
committed by GitHub
parent 6fe23fa846
commit 2babf27db5
6 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import "dart:io";
import "package:device_info_plus/device_info_plus.dart";
import "package:one_context/one_context.dart";
import "package:package_info_plus/package_info_plus.dart";
import "package:sentry_flutter/sentry_flutter.dart";
@ -148,7 +149,7 @@ Future<bool> sentryReportMessage(String message, {Map<String, String>? context})
/*
* Report an error message to sentry.io
*/
Future<void> sentryReportError(String source, dynamic error, dynamic stackTrace, {Map<String, String> context = const {}}) async {
Future<void> sentryReportError(String source, dynamic error, StackTrace? stackTrace, {Map<String, String> context = const {}}) async {
print("----- Sentry Intercepted error: $error -----");
print(stackTrace);
@ -192,6 +193,15 @@ Future<void> sentryReportError(String source, dynamic error, dynamic stackTrace,
// Ensure we pass the 'source' of the error
context["source"] = source;
if (OneContext.hasContext) {
final ctx = OneContext().context;
if (ctx != null) {
context["widget"] = ctx.widget.toString();
context["widgetType"] = ctx.widget.runtimeType.toString();
}
}
Sentry.configureScope((scope) {
scope.setExtra("server", server_info);
scope.setExtra("app", app_info);