Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joetaylor/add filter #84

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ module.exports = (grunt) ->
grunt.registerTask "uglify", "Uglifies bugsnag.js", () ->
exec = require("child_process").exec
done = this.async()
child = exec "./bin/uglify.coffee", (error, stdout, stderr) ->
console.log("Error running uglify.coffee: " + error) if error?
child = exec "./bin/uglify.js", (error, stdout, stderr) ->
console.log("Error running uglify.js: " + error) if error?
done(!error?)


Expand Down
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
40 changes: 0 additions & 40 deletions bin/uglify.coffee

This file was deleted.

40 changes: 40 additions & 0 deletions bin/uglify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node

fs = require('fs');
UglifyJS = require('uglifyjs');
version = require('../package.json').version;

ast = UglifyJS.parse(fs.readFileSync('src/bugsnag.js').toString('utf8'), {
filename: "bugsnag-"+version+".js"
});

compressor = UglifyJS.Compressor({
warnings: false, // A bucket-load of 'Boolean && always false'
global_defs: {
BUGSNAG_TESTING: undefined
}
});

ast.figure_out_scope()
ast = ast.transform(compressor);

ast.figure_out_scope();
ast.mangle_names();

source_map = UglifyJS.SourceMap({
file: "bugsnag-"+version+".min.js",
root: 'https://d2wy8f7a9ursnm.cloudfront.net/'
});

stream = UglifyJS.OutputStream({
source_map: source_map
});

ast.print(stream);

comment = "\n//# sourceMappingURL=//d2wy8f7a9ursnm.cloudfront.net/bugsnag-"+version+".min.map"

fs.writeFileSync('dist/bugsnag.min.js', stream.toString());
console.log("dist/bugsnag.min.js (v"+version+")");
fs.writeFileSync('dist/bugsnag.min.map', source_map.toString());
console.log("dist/bugsnag.min.map (v"+version+")");
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "bugsnag-js",
"version": "2.4.3",
"private": true,
"scripts": {
"test": "grunt test"
},
"main": "src/bugsnag.js",
"devDependencies": {
"grunt": "~0.4.2",
Expand Down
1 change: 1 addition & 0 deletions test/test.bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,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