@@ -14,29 +14,20 @@ yarn add @bugsnag/plugin-http-errors
1414
1515``` js
1616import Bugsnag from ' @bugsnag/js'
17- import createHttpErrorPlugin from ' @bugsnag/plugin-http-errors'
18-
19- const plugin = createHttpErrorPlugin ({
20- httpErrorCodes: [401 , { min: 404 , max: 499 }], // handle individual error codes or ranges of error codes
21- maxRequestSize: 5_000 , // don't capture requests over 5kb
22- onHttpError : ({ request, response }) => {
23- // Only handle 5xx errors
24- if (response .statusCode < 500 || response .statusCode > 599 ) return false
25-
26- // Exclude specific domains
27- if (request .url .indexOf (' redacted.domain.com' ) === 0 ) return false
28-
29- // Update properties on the reported request and response
30- request .url = ' [REDACTED]'
31- response .statusCode = 418
32-
33- return true // return value will determine whether the error is reported
34- }
35- })
17+ import BugsnagPluginHttpErrors from ' @bugsnag/plugin-http-errors'
3618
3719Bugsnag .start ({
38- apiKey: ' YOUR_API_KEY' ,
39- plugins: [plugin]
20+ apiKey: ' YOUR_API_KEY_HERE' ,
21+ plugins: [BugsnagPluginHttpErrors ({
22+ httpErrorCodes = [400 , 401 , { min: 450 : max 499 }], // Status codes to report as errors
23+ maxRequestSize = 20_000 , // Truncate the request and response body over this size (in kb)
24+ onHttpError : ({ request, response }) => {
25+ request .headers [' x-custom-header' ] = ' value' // Modify any request values before sending
26+ response .body = ' custom body' // Modify any response values before sending
27+
28+ return false // Don't report this request an as error
29+ }
30+ })]
4031})
4132```
4233
0 commit comments