@@ -88,6 +88,42 @@ void main() {
88
88
expect (event.breadcrumbs! .length, 1 );
89
89
expect (event.breadcrumbs! .first.message, 'event' );
90
90
});
91
+
92
+ test ('apply beforeBreadcrumb to native breadcrumbs' , () async {
93
+ fixture.options.enableScopeSync = true ;
94
+ fixture.options.beforeBreadcrumb = (breadcrumb, {hint}) {
95
+ if (breadcrumb? .message == 'native-mutated' ) {
96
+ return breadcrumb? .copyWith (message: 'native-mutated-applied' );
97
+ } else {
98
+ return null ;
99
+ }
100
+ };
101
+
102
+ final eventBreadcrumb = Breadcrumb (message: 'event' );
103
+ var event = SentryEvent (breadcrumbs: [eventBreadcrumb]);
104
+
105
+ final nativeMutatedBreadcrumb = Breadcrumb (message: 'native-mutated' );
106
+ final nativeDeletedBreadcrumb = Breadcrumb (message: 'native-deleted' );
107
+ Map <String , dynamic > loadContexts = {
108
+ 'breadcrumbs' : [
109
+ nativeMutatedBreadcrumb.toJson (),
110
+ nativeDeletedBreadcrumb.toJson (),
111
+ ]
112
+ };
113
+
114
+ final future = Future .value (loadContexts);
115
+ when (fixture.methodChannel.invokeMethod <dynamic >('loadContexts' ))
116
+ .thenAnswer ((_) => future);
117
+ // ignore: deprecated_member_use
118
+ _channel.setMockMethodCallHandler ((MethodCall methodCall) async {});
119
+
120
+ final integration = LoadContextsIntegration (fixture.methodChannel);
121
+ integration.call (fixture.hub, fixture.options);
122
+ event = (await fixture.options.eventProcessors.first.apply (event))! ;
123
+
124
+ expect (event.breadcrumbs! .length, 1 );
125
+ expect (event.breadcrumbs! .first.message, 'native-mutated-applied' );
126
+ });
91
127
});
92
128
}
93
129
0 commit comments