@@ -5,6 +5,7 @@ import { defineIntegration } from '../integration';
55import { logger } from '../utils-hoist/logger' ;
66import { getEventDescription } from '../utils-hoist/misc' ;
77import { stringMatchesSomePattern } from '../utils-hoist/string' ;
8+ import { getPossibleEventMessages } from '../utils/eventUtils' ;
89
910// "Script error." is hard coded into browsers for errors that it can't read.
1011// this is the result of a script being pulled in from an external domain and CORS.
@@ -117,7 +118,7 @@ function _isIgnoredError(event: Event, ignoreErrors?: Array<string | RegExp>): b
117118 return false ;
118119 }
119120
120- return _getPossibleEventMessages ( event ) . some ( message => stringMatchesSomePattern ( message , ignoreErrors ) ) ;
121+ return getPossibleEventMessages ( event ) . some ( message => stringMatchesSomePattern ( message , ignoreErrors ) ) ;
121122}
122123
123124function _isIgnoredTransaction ( event : Event , ignoreTransactions ?: Array < string | RegExp > ) : boolean {
@@ -147,32 +148,7 @@ function _isAllowedUrl(event: Event, allowUrls?: Array<string | RegExp>): boolea
147148 return ! url ? true : stringMatchesSomePattern ( url , allowUrls ) ;
148149}
149150
150- function _getPossibleEventMessages ( event : Event ) : string [ ] {
151- const possibleMessages : string [ ] = [ ] ;
152151
153- if ( event . message ) {
154- possibleMessages . push ( event . message ) ;
155- }
156-
157- let lastException ;
158- try {
159- // @ts -expect-error Try catching to save bundle size
160- lastException = event . exception . values [ event . exception . values . length - 1 ] ;
161- } catch ( e ) {
162- // try catching to save bundle size checking existence of variables
163- }
164-
165- if ( lastException ) {
166- if ( lastException . value ) {
167- possibleMessages . push ( lastException . value ) ;
168- if ( lastException . type ) {
169- possibleMessages . push ( `${ lastException . type } : ${ lastException . value } ` ) ;
170- }
171- }
172- }
173-
174- return possibleMessages ;
175- }
176152
177153function _isSentryError ( event : Event ) : boolean {
178154 try {
0 commit comments