@@ -165,6 +165,66 @@ const EXCEPTION_EVENT_WITH_LINKED_ERRORS: Event = {
165165 } ,
166166} ;
167167
168+ const USELESS_EXCEPTION_EVENT : Event = {
169+ exception : {
170+ values : [
171+ { } ,
172+ {
173+ mechanism : { type : 'onunhandledrejection' , handled : false } ,
174+ } ,
175+ ] ,
176+ } ,
177+ } ;
178+
179+ const USELESS_ERROR_EXCEPTION_EVENT : Event = {
180+ exception : {
181+ values : [ { type : 'Error' } , { } ] ,
182+ } ,
183+ } ;
184+
185+ const EVENT_WITH_MESSAGE : Event = {
186+ message : 'hello' ,
187+ } ;
188+
189+ const EVENT_WITH_STACKTRACE : Event = {
190+ exception : {
191+ values : [
192+ { } ,
193+ {
194+ stacktrace : {
195+ frames : [
196+ {
197+ abs_path : 'hello.js' ,
198+ } ,
199+ ] ,
200+ } ,
201+ } ,
202+ ] ,
203+ } ,
204+ } ;
205+
206+ const EVENT_WITH_TYPE : Event = {
207+ exception : {
208+ values : [
209+ { } ,
210+ {
211+ type : 'MyCustomError' ,
212+ } ,
213+ ] ,
214+ } ,
215+ } ;
216+
217+ const EVENT_WITH_VALUE : Event = {
218+ exception : {
219+ values : [
220+ { } ,
221+ {
222+ value : 'some error' ,
223+ } ,
224+ ] ,
225+ } ,
226+ } ;
227+
168228const SENTRY_EVENT : Event = {
169229 exception : {
170230 values : [
@@ -511,4 +571,36 @@ describe('InboundFilters', () => {
511571 expect ( eventProcessor ( MESSAGE_EVENT_WITH_NATIVE_LAST_FRAME , { } ) ) . toBe ( null ) ;
512572 } ) ;
513573 } ) ;
574+
575+ describe ( 'useless errors' , ( ) => {
576+ it ( "should drop event with exceptions that don't have any message, type or stack trace" , ( ) => {
577+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
578+ expect ( eventProcessor ( USELESS_EXCEPTION_EVENT , { } ) ) . toBe ( null ) ;
579+ } ) ;
580+
581+ it ( 'should drop event with just a generic error without stacktrace or message' , ( ) => {
582+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
583+ expect ( eventProcessor ( USELESS_ERROR_EXCEPTION_EVENT , { } ) ) . toBe ( null ) ;
584+ } ) ;
585+
586+ it ( 'should not drop event with a message' , ( ) => {
587+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
588+ expect ( eventProcessor ( EVENT_WITH_MESSAGE , { } ) ) . toBe ( EVENT_WITH_MESSAGE ) ;
589+ } ) ;
590+
591+ it ( 'should not drop event with an exception that has a type' , ( ) => {
592+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
593+ expect ( eventProcessor ( EVENT_WITH_TYPE , { } ) ) . toBe ( EVENT_WITH_TYPE ) ;
594+ } ) ;
595+
596+ it ( 'should not drop event with an exception that has a stacktrace' , ( ) => {
597+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
598+ expect ( eventProcessor ( EVENT_WITH_STACKTRACE , { } ) ) . toBe ( EVENT_WITH_STACKTRACE ) ;
599+ } ) ;
600+
601+ it ( 'should not drop event with an exception that has a value' , ( ) => {
602+ const eventProcessor = createInboundFiltersEventProcessor ( ) ;
603+ expect ( eventProcessor ( EVENT_WITH_VALUE , { } ) ) . toBe ( EVENT_WITH_VALUE ) ;
604+ } ) ;
605+ } ) ;
514606} ) ;
0 commit comments