mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Adds dialog before uploading error information
This commit is contained in:
parent
b6ccb57065
commit
14161c5d42
@ -1,9 +1,12 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info/device_info.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
import 'package:one_context/one_context.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import '../api.dart';
|
import '../api.dart';
|
||||||
|
|
||||||
@ -81,22 +84,7 @@ bool isInDebugMode() {
|
|||||||
return inDebugMode;
|
return inDebugMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _uploadErrorReport(dynamic error, dynamic stackTrace) async {
|
||||||
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
|
||||||
|
|
||||||
print('Caught error: $error');
|
|
||||||
|
|
||||||
// Errors thrown in development mode are unlikely to be interesting. You can
|
|
||||||
// check if you are running in dev mode using an assertion and omit sending
|
|
||||||
// the report.
|
|
||||||
if (isInDebugMode()) {
|
|
||||||
print(stackTrace);
|
|
||||||
print('In dev mode. Not sending report to Sentry.io.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print('Reporting to Sentry.io...');
|
|
||||||
|
|
||||||
final server_info = getServerInfo();
|
final server_info = getServerInfo();
|
||||||
final app_info = await getAppInfo();
|
final app_info = await getAppInfo();
|
||||||
final device_info = await getDeviceInfo();
|
final device_info = await getDeviceInfo();
|
||||||
@ -116,6 +104,45 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
||||||
|
|
||||||
|
print('Intercepted error: $error');
|
||||||
|
print(stackTrace);
|
||||||
|
|
||||||
|
// Errors thrown in development mode are unlikely to be interesting. You can
|
||||||
|
// check if you are running in dev mode using an assertion and omit sending
|
||||||
|
// the report.
|
||||||
|
if (isInDebugMode()) {
|
||||||
|
|
||||||
|
print('In dev mode. Not sending report to Sentry.io.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await OneContext().showDialog(
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: ListTile(
|
||||||
|
title: Text(I18N.of(OneContext().context).error),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.exclamationCircle),
|
||||||
|
subtitle: Text("An error occurred"),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Upload Error Report"),
|
||||||
|
onPressed: () {
|
||||||
|
_uploadErrorReport(error, stackTrace);
|
||||||
|
OneContext().pop();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
content: Text(error.toString()),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<bool> sentryReportMessage(String message) async {
|
Future<bool> sentryReportMessage(String message) async {
|
||||||
|
|
||||||
final server_info = getServerInfo();
|
final server_info = getServerInfo();
|
||||||
|
@ -5,19 +5,16 @@ import 'package:InvenTree/inventree/sentry.dart';
|
|||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
|
||||||
import 'package:InvenTree/widget/home.dart';
|
import 'package:InvenTree/widget/home.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:one_context/one_context.dart';
|
||||||
|
|
||||||
import 'dsn.dart';
|
import 'dsn.dart';
|
||||||
|
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
|
||||||
|
|
||||||
@ -58,6 +55,8 @@ class InvenTreeApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
builder: OneContext().builder,
|
||||||
|
navigatorKey: OneContext().key,
|
||||||
onGenerateTitle: (BuildContext context) => I18N.of(context).appTitle,
|
onGenerateTitle: (BuildContext context) => I18N.of(context).appTitle,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.lightBlue,
|
primarySwatch: Colors.lightBlue,
|
||||||
|
@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> confirmationDialog(BuildContext context, String title, String text, {String acceptText, String rejectText, Function onAccept, Function onReject}) async {
|
Future<void> confirmationDialog(BuildContext context, String title, String text, {String acceptText, String rejectText, Function onAccept, Function onReject}) async {
|
||||||
|
49
pubspec.lock
49
pubspec.lock
@ -308,6 +308,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.0"
|
version: "0.3.0"
|
||||||
|
one_context:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: one_context
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.0"
|
||||||
package_info:
|
package_info:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -434,6 +441,48 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.4"
|
version: "4.0.4"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.12+4"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.2+4"
|
||||||
|
shared_preferences_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.1+11"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.4"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.2+7"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.2+3"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -7,7 +7,7 @@ description: InvenTree stock management
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 0.1.0
|
version: 0.1.0+2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.1.0 <3.0.0"
|
sdk: ">=2.1.0 <3.0.0"
|
||||||
@ -37,6 +37,7 @@ dependencies:
|
|||||||
camera:
|
camera:
|
||||||
path_provider: ^1.6.27 # Local file storage
|
path_provider: ^1.6.27 # Local file storage
|
||||||
sembast: ^2.4.9 # NoSQL data storage
|
sembast: ^2.4.9 # NoSQL data storage
|
||||||
|
one_context: ^0.5.0 # Dialogs without requiring context
|
||||||
path:
|
path:
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user