allow sentry error levels to be set

pull/1116/head
ggurdin 2 years ago
parent 29a3946e73
commit ffb532b1dd

@ -2,6 +2,7 @@ import 'package:fluffychat/pangea/constants/language_keys.dart';
import 'package:fluffychat/pangea/models/speech_to_text_models.dart'; import 'package:fluffychat/pangea/models/speech_to_text_models.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
/// this class is contained within a [RepresentationEvent] /// this class is contained within a [RepresentationEvent]
/// this event is the child of a [EventTypes.Message] /// this event is the child of a [EventTypes.Message]
@ -60,6 +61,7 @@ class PangeaRepresentation {
e: Exception("Language code cannot be 'unk'"), e: Exception("Language code cannot be 'unk'"),
s: StackTrace.current, s: StackTrace.current,
data: {"rep_content": json}, data: {"rep_content": json},
level: SentryLevel.warning,
); );
} }
return PangeaRepresentation( return PangeaRepresentation(

@ -12,25 +12,6 @@ class ErrorHandler {
ErrorHandler(); ErrorHandler();
static Future<void> initialize() async { static Future<void> initialize() async {
FutureOr<void> Function(Scope)? withScope(
Scope scope,
FlutterErrorDetails details,
) {
// if (details.exception is http.Response) {
// final res = details.exception as http.Response;
// scope.addBreadcrumb(
// Breadcrumb.http(
// url: res.request?.url ?? Uri(path: "not available"),
// method: "where does method go?",
// statusCode: res.statusCode,
// ),
// );
// } else {
// debugPrint("not an http exception ${details.exception.toString()}");
// }
return null;
}
await SentryFlutter.init( await SentryFlutter.init(
(options) { (options) {
options.dsn = Environment.sentryDsn; options.dsn = Environment.sentryDsn;
@ -41,10 +22,6 @@ class ErrorHandler {
: Environment.isStaging : Environment.isStaging
? "staging" ? "staging"
: "productionC"; : "productionC";
// options.beforeSend = (event, {hint}) {
// debugger(when: kDebugMode);
// return null;
// };
}, },
); );
@ -54,7 +31,6 @@ class ErrorHandler {
Sentry.captureException( Sentry.captureException(
details.exception, details.exception,
stackTrace: details.stack ?? StackTrace.current, stackTrace: details.stack ?? StackTrace.current,
withScope: (scope) => withScope(scope, details),
); );
} }
}; };
@ -70,6 +46,7 @@ class ErrorHandler {
StackTrace? s, StackTrace? s,
String? m, String? m,
Map<String, dynamic>? data, Map<String, dynamic>? data,
SentryLevel level = SentryLevel.error,
}) async { }) async {
if (m != null) debugPrint("error message: $m"); if (m != null) debugPrint("error message: $m");
if ((e ?? m) != null) debugPrint("error to string: ${e?.toString() ?? m}"); if ((e ?? m) != null) debugPrint("error to string: ${e?.toString() ?? m}");
@ -77,19 +54,13 @@ class ErrorHandler {
Sentry.addBreadcrumb(Breadcrumb.fromJson(data)); Sentry.addBreadcrumb(Breadcrumb.fromJson(data));
debugPrint(data.toString()); debugPrint(data.toString());
} }
FlutterError.reportError(
FlutterErrorDetails( Sentry.captureException(
exception: e ?? Exception(m ?? "no message supplied"), e ?? Exception(m ?? "no message supplied"),
stack: s, stackTrace: s ?? StackTrace.current,
library: 'Pangea', withScope: (scope) {
context: ErrorSummary(e?.toString() ?? "error not defined"), scope.level = level;
stackFilter: (input) => input.where( },
(e) => !(e.contains("org-dartlang-sdk") ||
e.contains("future_impl") ||
e.contains("microtask") ||
e.contains("async_patch")),
),
),
); );
} }
} }

@ -118,7 +118,7 @@ dependencies:
material_symbols_icons: ^4.2741.0 material_symbols_icons: ^4.2741.0
open_file: ^3.3.2 open_file: ^3.3.2
purchases_flutter: ^6.26.0 purchases_flutter: ^6.26.0
sentry_flutter: ^7.19.0 sentry_flutter: ^8.2.0
shimmer: ^3.0.0 shimmer: ^3.0.0
syncfusion_flutter_xlsio: ^25.1.40 syncfusion_flutter_xlsio: ^25.1.40
# Pangea# # Pangea#

Loading…
Cancel
Save