Skip to content

Commit a7b8b28

Browse files
committed
refactor
1 parent f1df16d commit a7b8b28

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

supabase/lib/src/sentry_supabase_client.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,33 @@ class SentrySupabaseClient extends BaseClient {
7272
final url = request.url;
7373
final table = url.pathSegments.last;
7474
final description = 'from($table)';
75+
final query = _readQuery(request);
76+
final body = _readBody(table, request);
7577

76-
final query = <String>[];
77-
for (final entry in request.url.queryParameters.entries) {
78-
query.add(_translateFiltersIntoMethods(entry.key, entry.value));
78+
if (_breadcrumbs) {
79+
_addBreadcrumb(description, operation, query, body);
7980
}
81+
}
82+
83+
List<String> _readQuery(BaseRequest request) {
84+
return request.url.queryParameters.entries
85+
.map(
86+
(entry) => _translateFiltersIntoMethods(entry.key, entry.value),
87+
)
88+
.toList();
89+
}
8090

91+
Map<String, dynamic>? _readBody(String table, BaseRequest request) {
8192
final bodyString =
8293
request is Request && request.body.isNotEmpty ? request.body : null;
8394
var body = bodyString != null ? jsonDecode(bodyString) : null;
8495

85-
if (_redactRequestBody != null) {
86-
for (final entry in body?.entries ?? []) {
96+
if (body != null && _redactRequestBody != null) {
97+
for (final entry in body.entries) {
8798
body[entry.key] = _redactRequestBody(table, entry.key, entry.value);
8899
}
89100
}
90-
91-
if (_breadcrumbs) {
92-
_addBreadcrumb(description, operation, query, body);
93-
}
101+
return body;
94102
}
95103

96104
void _addBreadcrumb(

0 commit comments

Comments
 (0)