Skip to content

Commit

Permalink
made docs about beforeNotify clearer and tests a little safer
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Taylor authored and ConradIrwin committed Oct 11, 2014
1 parent a5a77b4 commit dfbbc60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ Bugsnag.appVersion = "2.0.14";

To have more fine grained control over what errors are sent to Bugsnag, you can
implement a `beforeNotify` function. If you want to halt the notification completely,
return `false` from this function. You can also add metaData by editing the `metaData`
parameter.
return `false` from this function.

```javascript
Bugsnag.beforeNotify = function(payload) {
Expand All @@ -251,6 +250,15 @@ Bugsnag.beforeNotify = function(payload) {
}
```

You can modify the `payload` or `metaData` by editing the parameters.

```javascript
Bugsnag.beforeNotify = function(payload, metaData) {
// Filter out sensitive information
payload.url = "http://redacted.com";
}
```

The `payload` parameter contains the error's `name`, `message`, `file` and
`lineNumber` where available, as well as some additional fields that we either
show on your Bugsnag dashboard, or use for grouping.
Expand Down
1 change: 1 addition & 0 deletions test/test.bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ describe("Bugsnag", function () {
Bugsnag.notifyException(new Error("Example error"));

assert.equal(requestData().params.url, "http://redacted.com");
assert(Bugsnag.testRequest.called, "Bugsnag.testRequest should have been called");
});

it("should contain 'warning' as the default severity", function () {
Expand Down

0 comments on commit dfbbc60

Please sign in to comment.