Skip to content

Commit

Permalink
Merge pull request #191 from pangeachat/sentry-warnings
Browse files Browse the repository at this point in the history
allow sentry error levels to be set
  • Loading branch information
ggurdin authored May 14, 2024
2 parents f716f1c + ffb532b commit f7fa048
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 38 deletions.
2 changes: 2 additions & 0 deletions lib/pangea/models/representation_content_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/utils/error_handler.dart';
import 'package:matrix/matrix.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

/// this class is contained within a [RepresentationEvent]
/// this event is the child of a [EventTypes.Message]
Expand Down Expand Up @@ -60,6 +61,7 @@ class PangeaRepresentation {
e: Exception("Language code cannot be 'unk'"),
s: StackTrace.current,
data: {"rep_content": json},
level: SentryLevel.warning,
);
}
return PangeaRepresentation(
Expand Down
45 changes: 8 additions & 37 deletions lib/pangea/utils/error_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ class ErrorHandler {
ErrorHandler();

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(
(options) {
options.dsn = Environment.sentryDsn;
Expand All @@ -41,10 +22,6 @@ class ErrorHandler {
: Environment.isStaging
? "staging"
: "productionC";
// options.beforeSend = (event, {hint}) {
// debugger(when: kDebugMode);
// return null;
// };
},
);

Expand All @@ -54,7 +31,6 @@ class ErrorHandler {
Sentry.captureException(
details.exception,
stackTrace: details.stack ?? StackTrace.current,
withScope: (scope) => withScope(scope, details),
);
}
};
Expand All @@ -70,26 +46,21 @@ class ErrorHandler {
StackTrace? s,
String? m,
Map<String, dynamic>? data,
SentryLevel level = SentryLevel.error,
}) async {
if (m != null) debugPrint("error message: $m");
if ((e ?? m) != null) debugPrint("error to string: ${e?.toString() ?? m}");
if (data != null) {
Sentry.addBreadcrumb(Breadcrumb.fromJson(data));
debugPrint(data.toString());
}
FlutterError.reportError(
FlutterErrorDetails(
exception: e ?? Exception(m ?? "no message supplied"),
stack: s,
library: 'Pangea',
context: ErrorSummary(e?.toString() ?? "error not defined"),
stackFilter: (input) => input.where(
(e) => !(e.contains("org-dartlang-sdk") ||
e.contains("future_impl") ||
e.contains("microtask") ||
e.contains("async_patch")),
),
),

Sentry.captureException(
e ?? Exception(m ?? "no message supplied"),
stackTrace: s ?? StackTrace.current,
withScope: (scope) {
scope.level = level;
},
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ dependencies:
material_symbols_icons: ^4.2741.0
open_file: ^3.3.2
purchases_flutter: ^6.26.0
sentry_flutter: ^7.19.0
sentry_flutter: ^8.2.0
shimmer: ^3.0.0
syncfusion_flutter_xlsio: ^25.1.40
# Pangea#
Expand Down

0 comments on commit f7fa048

Please sign in to comment.