fix: improve error reporting data sanitization
This commit is contained in:
@@ -81,6 +81,7 @@ void main() async {
|
||||
options.attachStacktrace = true;
|
||||
options.enableAutoSessionTracking = false;
|
||||
options.beforeSend = _beforeSend;
|
||||
options.beforeBreadcrumb = _beforeBreadcrumb;
|
||||
},
|
||||
appRunner: () async {
|
||||
// Initialize settings first to get saved locale
|
||||
@@ -150,6 +151,19 @@ void main() async {
|
||||
);
|
||||
}
|
||||
|
||||
Breadcrumb? _beforeBreadcrumb(Breadcrumb? breadcrumb, Hint hint) {
|
||||
if (breadcrumb == null) return null;
|
||||
|
||||
final message = breadcrumb.message;
|
||||
final data = breadcrumb.data;
|
||||
if (message == null && (data == null || data.isEmpty)) return breadcrumb;
|
||||
|
||||
return breadcrumb.copyWith(
|
||||
message: message != null ? LogRedactionManager.redact(message) : null,
|
||||
data: data?.map((k, v) => MapEntry(k, v is String ? LogRedactionManager.redact(v) : v)),
|
||||
);
|
||||
}
|
||||
|
||||
FutureOr<SentryEvent?> _beforeSend(SentryEvent event, Hint hint) {
|
||||
// Drop event if user opted out of crash reporting
|
||||
final instance = SettingsService.instanceOrNull;
|
||||
|
||||
Reference in New Issue
Block a user