Skip to content

Commit 11b821b

Browse files
authored
Ref: Remove stackFrameFilter in favor of beforeSendCallback (#125)
1 parent 2cc1d78 commit 11b821b

File tree

9 files changed

+23
-46
lines changed

9 files changed

+23
-46
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- Ref: Event now is SentryEvent and added GPU #121
2929
- Feat: before breadcrumb and scope ref. #122
3030
- Ref: Hint is passed across Sentry static class, Hub and Client #124
31+
- Ref: Remove stackFrameFilter in favor of beforeSendCallback #125
3132

3233
# `package:sentry` changelog
3334

dart/lib/src/client.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'client_stub.dart'
88
if (dart.library.html) 'browser_client.dart'
99
if (dart.library.io) 'io_client.dart';
1010
import 'protocol.dart';
11-
import 'stack_trace.dart';
1211
import 'utils.dart';
1312
import 'version.dart';
1413

@@ -97,7 +96,6 @@ abstract class SentryClient {
9796
/// Reports an [event] to Sentry.io.
9897
Future<SentryId> captureEvent(
9998
SentryEvent event, {
100-
StackFrameFilter stackFrameFilter,
10199
Scope scope,
102100
dynamic hint,
103101
}) async {
@@ -128,7 +126,6 @@ abstract class SentryClient {
128126

129127
mergeAttributes(
130128
event.toJson(
131-
stackFrameFilter: stackFrameFilter,
132129
origin: origin,
133130
),
134131
into: data,

dart/lib/src/noop_client.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'client.dart';
44
import 'protocol.dart';
55
import 'scope.dart';
66
import 'sentry_options.dart';
7-
import 'stack_trace.dart';
87

98
class NoOpSentryClient implements SentryClient {
109
NoOpSentryClient._();
@@ -37,15 +36,14 @@ class NoOpSentryClient implements SentryClient {
3736
@override
3837
Future<SentryId> captureEvent(
3938
SentryEvent event, {
40-
StackFrameFilter stackFrameFilter,
4139
Scope scope,
4240
dynamic hint,
4341
}) =>
4442
Future.value(SentryId.empty());
4543

4644
@override
4745
Future<SentryId> captureException(
48-
dynamic throwable, {
46+
throwable, {
4947
dynamic stackTrace,
5048
Scope scope,
5149
dynamic hint,

dart/lib/src/protocol/sentry_event.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class SentryEvent {
193193
);
194194

195195
/// Serializes this event to JSON.
196-
Map<String, dynamic> toJson(
197-
{StackFrameFilter stackFrameFilter, String origin}) {
196+
Map<String, dynamic> toJson({String origin}) {
198197
final json = <String, dynamic>{};
199198

200199
if (eventId != null) {
@@ -254,7 +253,6 @@ class SentryEvent {
254253
json['stacktrace'] = <String, dynamic>{
255254
'frames': encodeStackTrace(
256255
exception.stackTrace,
257-
stackFrameFilter: stackFrameFilter,
258256
origin: origin,
259257
),
260258
};
@@ -265,7 +263,6 @@ class SentryEvent {
265263
json['stacktrace'] = <String, dynamic>{
266264
'frames': encodeStackTrace(
267265
stackTrace,
268-
stackFrameFilter: stackFrameFilter,
269266
origin: origin,
270267
),
271268
};

dart/lib/src/stack_trace.dart

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44

55
import 'package:stack_trace/stack_trace.dart';
66

7-
/// Used to filter or modify stack frames before sending the stack trace.
8-
///
9-
/// The input stack frames are in the Sentry.io JSON format. The output
10-
/// stack frames must follow the same format.
11-
///
12-
/// Detailed documentation about the stack trace format is on Sentry.io's
13-
/// web-site: https://docs.sentry.io/development/sdk-dev/overview/.
14-
typedef StackFrameFilter = List<Map<String, dynamic>> Function(
15-
List<Map<String, dynamic>>);
16-
177
/// Sentry.io JSON encoding of a stack frame for the asynchronous suspension,
188
/// which is the gap between asynchronous calls.
199
const Map<String, dynamic> asynchronousGapFrameJson = <String, dynamic>{
@@ -25,7 +15,6 @@ const Map<String, dynamic> asynchronousGapFrameJson = <String, dynamic>{
2515
/// [stackTrace] must be [String] or [StackTrace].
2616
List<Map<String, dynamic>> encodeStackTrace(
2717
dynamic stackTrace, {
28-
StackFrameFilter stackFrameFilter,
2918
String origin,
3019
}) {
3120
assert(stackTrace is String || stackTrace is StackTrace);
@@ -47,8 +36,7 @@ List<Map<String, dynamic>> encodeStackTrace(
4736
}
4837
}
4938

50-
final jsonFrames = frames.reversed.toList();
51-
return stackFrameFilter != null ? stackFrameFilter(jsonFrames) : jsonFrames;
39+
return frames.reversed.toList();
5240
}
5341

5442
Map<String, dynamic> encodeStackTraceFrame(Frame frame, {String origin}) {

dart/test/event_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ void main() {
131131
'stacktrace': {
132132
'frames': encodeStackTrace(
133133
error.stackTrace,
134-
stackFrameFilter: null,
135134
origin: null,
136135
)
137136
}

dart/test/hub_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void main() {
5757
client.captureEvent(
5858
fakeEvent,
5959
scope: captureAnyNamed('scope'),
60-
stackFrameFilter: null,
6160
),
6261
).captured.first,
6362
Scope(options),
@@ -112,7 +111,6 @@ void main() {
112111
client.captureEvent(
113112
fakeEvent,
114113
scope: captureAnyNamed('scope'),
115-
stackFrameFilter: null,
116114
),
117115
).captured.first,
118116
Scope(SentryOptions(dsn: fakeDsn))
@@ -145,7 +143,6 @@ void main() {
145143
client2.captureEvent(
146144
fakeEvent,
147145
scope: anyNamed('scope'),
148-
stackFrameFilter: null,
149146
),
150147
).called(1);
151148
});

dart/test/sentry_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ void main() {
2424
client.captureEvent(
2525
fakeEvent,
2626
scope: anyNamed('scope'),
27-
stackFrameFilter: null,
2827
),
2928
).called(1);
3029
});

dart/test/stack_trace_test.dart

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,25 @@ void main() {
7979
]);
8080
});
8181

82-
test('allows changing the stack frame list before sending', () {
83-
// ignore: omit_local_variable_types
84-
final StackFrameFilter filter =
85-
(list) => list.where((f) => f['abs_path'] != 'secret.dart').toList();
82+
// TODO: use beforeSend to filter stack frames
83+
// test('allows changing the stack frame list before sending', () {
84+
// // ignore: omit_local_variable_types
85+
// final StackFrameFilter filter =
86+
// (list) => list.where((f) => f['abs_path'] != 'secret.dart').toList();
8687

87-
expect(encodeStackTrace('''
88-
#0 baz (file:///pathto/test.dart:50:3)
89-
#1 bar (file:///pathto/secret.dart:46:9)
90-
''', stackFrameFilter: filter), [
91-
{
92-
'abs_path': 'test.dart',
93-
'function': 'baz',
94-
'lineno': 50,
95-
'colno': 3,
96-
'in_app': true,
97-
'filename': 'test.dart'
98-
},
99-
]);
100-
});
88+
// expect(encodeStackTrace('''
89+
// #0 baz (file:///pathto/test.dart:50:3)
90+
// #1 bar (file:///pathto/secret.dart:46:9)
91+
// ''', stackFrameFilter: filter), [
92+
// {
93+
// 'abs_path': 'test.dart',
94+
// 'function': 'baz',
95+
// 'lineno': 50,
96+
// 'colno': 3,
97+
// 'in_app': true,
98+
// 'filename': 'test.dart'
99+
// },
100+
// ]);
101+
// });
101102
});
102103
}

0 commit comments

Comments
 (0)