Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Ref: SentryId generates UUID #119
- Ref: Event now is SentryEvent and added GPU #121
- Feat: before breadcrumb and scope ref. #122
- Feat: Remove stackFrameFilter in favor of beforeSendCallback

# `package:sentry` changelog

Expand Down
3 changes: 0 additions & 3 deletions dart/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'client_stub.dart'
if (dart.library.html) 'browser_client.dart'
if (dart.library.io) 'io_client.dart';
import 'protocol.dart';
import 'stack_trace.dart';
import 'utils.dart';
import 'version.dart';

Expand Down Expand Up @@ -97,7 +96,6 @@ abstract class SentryClient {
/// Reports an [event] to Sentry.io.
Future<SentryId> captureEvent(
SentryEvent event, {
StackFrameFilter stackFrameFilter,
Scope scope,
}) async {
final now = options.clock();
Expand Down Expand Up @@ -127,7 +125,6 @@ abstract class SentryClient {

mergeAttributes(
event.toJson(
stackFrameFilter: stackFrameFilter,
origin: origin,
),
into: data,
Expand Down
8 changes: 6 additions & 2 deletions dart/lib/src/noop_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ class NoOpSentryClient implements SentryClient {
Map<String, String> buildHeaders(String authHeader) => {};

@override
Future<SentryId> captureEvent(SentryEvent event, {stackFrameFilter, scope}) =>
Future<SentryId> captureEvent(SentryEvent event, {Scope scope}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace, scope}) =>
Future<SentryId> captureException(
throwable, {
dynamic stackTrace,
Scope scope,
}) =>
Future.value(SentryId.empty());

@override
Expand Down
5 changes: 1 addition & 4 deletions dart/lib/src/protocol/sentry_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ class SentryEvent {
);

/// Serializes this event to JSON.
Map<String, dynamic> toJson(
{StackFrameFilter stackFrameFilter, String origin}) {
Map<String, dynamic> toJson({String origin}) {
final json = <String, dynamic>{};

if (eventId != null) {
Expand Down Expand Up @@ -254,7 +253,6 @@ class SentryEvent {
json['stacktrace'] = <String, dynamic>{
'frames': encodeStackTrace(
exception.stackTrace,
stackFrameFilter: stackFrameFilter,
origin: origin,
),
};
Expand All @@ -265,7 +263,6 @@ class SentryEvent {
json['stacktrace'] = <String, dynamic>{
'frames': encodeStackTrace(
stackTrace,
stackFrameFilter: stackFrameFilter,
origin: origin,
),
};
Expand Down
14 changes: 1 addition & 13 deletions dart/lib/src/stack_trace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@

import 'package:stack_trace/stack_trace.dart';

/// Used to filter or modify stack frames before sending the stack trace.
///
/// The input stack frames are in the Sentry.io JSON format. The output
/// stack frames must follow the same format.
///
/// Detailed documentation about the stack trace format is on Sentry.io's
/// web-site: https://docs.sentry.io/development/sdk-dev/overview/.
typedef StackFrameFilter = List<Map<String, dynamic>> Function(
List<Map<String, dynamic>>);

/// Sentry.io JSON encoding of a stack frame for the asynchronous suspension,
/// which is the gap between asynchronous calls.
const Map<String, dynamic> asynchronousGapFrameJson = <String, dynamic>{
Expand All @@ -25,7 +15,6 @@ const Map<String, dynamic> asynchronousGapFrameJson = <String, dynamic>{
/// [stackTrace] must be [String] or [StackTrace].
List<Map<String, dynamic>> encodeStackTrace(
dynamic stackTrace, {
StackFrameFilter stackFrameFilter,
String origin,
}) {
assert(stackTrace is String || stackTrace is StackTrace);
Expand All @@ -47,8 +36,7 @@ List<Map<String, dynamic>> encodeStackTrace(
}
}

final jsonFrames = frames.reversed.toList();
return stackFrameFilter != null ? stackFrameFilter(jsonFrames) : jsonFrames;
return frames.reversed.toList();
}

Map<String, dynamic> encodeStackTraceFrame(Frame frame, {String origin}) {
Expand Down
1 change: 0 additions & 1 deletion dart/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ void main() {
'stacktrace': {
'frames': encodeStackTrace(
error.stackTrace,
stackFrameFilter: null,
origin: null,
)
}
Expand Down
3 changes: 0 additions & 3 deletions dart/test/hub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void main() {
client.captureEvent(
fakeEvent,
scope: captureAnyNamed('scope'),
stackFrameFilter: null,
),
).captured.first,
Scope(options),
Expand Down Expand Up @@ -112,7 +111,6 @@ void main() {
client.captureEvent(
fakeEvent,
scope: captureAnyNamed('scope'),
stackFrameFilter: null,
),
).captured.first,
Scope(SentryOptions(dsn: fakeDsn))
Expand Down Expand Up @@ -145,7 +143,6 @@ void main() {
client2.captureEvent(
fakeEvent,
scope: anyNamed('scope'),
stackFrameFilter: null,
),
).called(1);
});
Expand Down
1 change: 0 additions & 1 deletion dart/test/sentry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ void main() {
client.captureEvent(
fakeEvent,
scope: anyNamed('scope'),
stackFrameFilter: null,
),
).called(1);
});
Expand Down
37 changes: 19 additions & 18 deletions dart/test/stack_trace_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,25 @@ void main() {
]);
});

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

expect(encodeStackTrace('''
#0 baz (file:///pathto/test.dart:50:3)
#1 bar (file:///pathto/secret.dart:46:9)
''', stackFrameFilter: filter), [
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'colno': 3,
'in_app': true,
'filename': 'test.dart'
},
]);
});
// expect(encodeStackTrace('''
// #0 baz (file:///pathto/test.dart:50:3)
// #1 bar (file:///pathto/secret.dart:46:9)
// ''', stackFrameFilter: filter), [
// {
// 'abs_path': 'test.dart',
// 'function': 'baz',
// 'lineno': 50,
// 'colno': 3,
// 'in_app': true,
// 'filename': 'test.dart'
// },
// ]);
// });
});
}