@@ -34,8 +34,9 @@ const networkInstrumentation = (
3434 onHttpError
3535 } = config
3636
37- // Normalize httpErrorCodes to an array
38- const normalizedStatusCodes = Array . isArray ( httpErrorCodes ) ? httpErrorCodes : [ httpErrorCodes ]
37+ // Normalize httpErrorCodes to an array of {min, max} objects
38+ const normalizedStatusCodes = ( Array . isArray ( httpErrorCodes ) ? httpErrorCodes : [ httpErrorCodes ] )
39+ . map ( code => typeof code === 'number' ? { min : code , max : code } : code )
3940
4041 let restoreFunctions : Array < ( ) => void > = [ ]
4142 const plugin : Plugin = {
@@ -47,14 +48,12 @@ const networkInstrumentation = (
4748 // Auto-load request tracker if not present
4849 if ( ! requestTrackerPlugin ) {
4950 try {
50- // @ts -ignore
5151 const { createRequestTrackerPlugin } = require ( '@bugsnag/request-tracker' )
5252 const trackerPlugin = createRequestTrackerPlugin ( [ ] , global )
53- // @ts -ignore
5453 client . _loadPlugin ( trackerPlugin )
5554 requestTrackerPlugin = client . getPlugin && client . getPlugin ( 'requestTracker' )
5655 } catch ( error : any ) {
57- client . _logger ?. warn ?.( 'Failed to auto-load request tracker, using direct fetch patching:' , error . message )
56+ client . _logger ?. warn ?.( 'Failed to auto-load request tracker, using direct fetch patching: ' + error . message )
5857 }
5958 }
6059
@@ -104,12 +103,14 @@ const networkInstrumentation = (
104103 httpMethod : method ,
105104 headers : startContext . headers ,
106105 params : redactValues ( requestParams , client . _config . redactedKeys ) ,
107- bodyLength : startContext . body ? startContext . body . length : undefined
106+ bodyLength : startContext . body ? startContext . body . length : undefined ,
107+ body : undefined as string | undefined
108108 }
109109 const responseObj = {
110110 statusCode : endContext . status ,
111111 headers : endContext . headers ,
112- bodyLength : endContext . body ? endContext . body . length : undefined
112+ bodyLength : endContext . body ? endContext . body . length : undefined ,
113+ body : undefined as string | undefined
113114 }
114115
115116 // Call onHttpError callback if provided
@@ -142,7 +143,6 @@ const networkInstrumentation = (
142143 severityReason : { type : 'httpError' }
143144 }
144145
145- // @ts -ignore
146146 const event : Event = client . Event . create (
147147 error ,
148148 true ,
0 commit comments