mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-17 04:35:26 +00:00
Upload custom message when server returns error code >= 500
This commit is contained in:
@ -84,6 +84,40 @@ bool isInDebugMode() {
|
||||
return inDebugMode;
|
||||
}
|
||||
|
||||
Future<bool> sentryReportMessage(String message, {Map<String, String>? context}) async {
|
||||
|
||||
final server_info = getServerInfo();
|
||||
final app_info = await getAppInfo();
|
||||
final device_info = await getDeviceInfo();
|
||||
|
||||
print("Sending user message to Sentry: ${message}");
|
||||
|
||||
if (isInDebugMode()) {
|
||||
|
||||
print('----- In dev mode. Not sending message to Sentry.io -----');
|
||||
return true;
|
||||
}
|
||||
|
||||
Sentry.configureScope((scope) {
|
||||
scope.setExtra("server", server_info);
|
||||
scope.setExtra("app", app_info);
|
||||
scope.setExtra("device", device_info);
|
||||
|
||||
if (context != null) {
|
||||
scope.setExtra("context", context);
|
||||
}
|
||||
});
|
||||
|
||||
final sentryId = await Sentry.captureMessage(message).catchError((error) {
|
||||
print("Error uploading sentry messages...");
|
||||
print(error);
|
||||
return null;
|
||||
});
|
||||
|
||||
return sentryId != null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
||||
|
||||
print('----- Sentry Intercepted error: $error -----');
|
||||
@ -115,27 +149,3 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
||||
print("Uploaded information to Sentry.io : ${response.toString()}");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Future<bool> 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;
|
||||
}
|
Reference in New Issue
Block a user