Visitar URL original
Fixed "Culprit" recording in Sentry (#14) · creatorpiyush/packages@5b5cecf · GitHub
Skip to content

Commit 5b5cecf

Browse files
slightfootyjbanov
authored andcommitted
Fixed "Culprit" recording in Sentry (flutter#14)
* Fix stack-trace frame ordering. In order for `Culprit` to be logged correctly it should have the latest frame at th top. * Updated tests. * Fix stack-frame tests. * dartfmt over test/sentry_test.dart
1 parent 1d859a2 commit 5b5cecf

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎lib/src/stack_trace.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ List<Map<String, dynamic>> encodeStackTrace(dynamic stackTrace) {
2424
frames.addAll(chain.traces[t].frames.map(encodeStackTraceFrame));
2525
if (t < chain.traces.length - 1) frames.add(asynchronousGapFrameJson);
2626
}
27-
return frames;
27+
return frames.reversed.toList();
2828
}
2929

3030
Map<String, dynamic> encodeStackTraceFrame(Frame frame) {

‎test/sentry_test.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ void main() {
9393
expect(stacktrace['frames'], const isInstanceOf<List>());
9494
expect(stacktrace['frames'], isNotEmpty);
9595

96-
final Map<String, dynamic> topFrame = stacktrace['frames'].first;
96+
final Map<String, dynamic> topFrame =
97+
(stacktrace['frames'] as Iterable<dynamic>).last;
9798
expect(topFrame.keys,
9899
<String>['abs_path', 'function', 'lineno', 'in_app', 'filename']);
99100
expect(topFrame['abs_path'], 'sentry_test.dart');

‎test/stack_trace_test.dart‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ void main() {
3434
'''), [
3535
{
3636
'abs_path': 'test.dart',
37-
'function': 'baz',
38-
'lineno': 50,
37+
'function': 'bar',
38+
'lineno': 46,
3939
'in_app': true,
4040
'filename': 'test.dart'
4141
},
4242
{
4343
'abs_path': 'test.dart',
44-
'function': 'bar',
45-
'lineno': 46,
44+
'function': 'baz',
45+
'lineno': 50,
4646
'in_app': true,
4747
'filename': 'test.dart'
48-
}
48+
},
4949
]);
5050
});
5151

@@ -57,8 +57,8 @@ void main() {
5757
'''), [
5858
{
5959
'abs_path': 'test.dart',
60-
'function': 'baz',
61-
'lineno': 50,
60+
'function': 'bar',
61+
'lineno': 46,
6262
'in_app': true,
6363
'filename': 'test.dart'
6464
},
@@ -67,11 +67,11 @@ void main() {
6767
},
6868
{
6969
'abs_path': 'test.dart',
70-
'function': 'bar',
71-
'lineno': 46,
70+
'function': 'baz',
71+
'lineno': 50,
7272
'in_app': true,
7373
'filename': 'test.dart'
74-
}
74+
},
7575
]);
7676
});
7777
});

0 commit comments

Comments
 (0)