honeybadger-js
Advanced tools
Comparing version 0.4.2 to 0.4.3
{ | ||
"name": "honeybadger", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"homepage": "https://github.com/honeybadger-io/honeybadger-js", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -8,2 +8,6 @@ # Change Log | ||
## [0.4.3] - 2016-09-26 | ||
### Added | ||
- Added option to send params and cookies. | ||
## [0.4.2] - 2016-04-14 | ||
@@ -10,0 +14,0 @@ ### Fixed |
/* | ||
honeybadger.js v0.4.2 | ||
honeybadger.js v0.4.3 | ||
A JavaScript Notifier for Honeybadger | ||
@@ -50,3 +50,3 @@ https://github.com/honeybadger-io/honeybadger-js | ||
}(this, function () { | ||
var VERSION = '0.4.2', | ||
var VERSION = '0.4.3', | ||
NOTIFIER = { | ||
@@ -92,2 +92,15 @@ name: 'honeybadger.js', | ||
function encodeCookie(object) { | ||
if (typeof object !== 'object') { | ||
return undefined; | ||
} | ||
var cookies = []; | ||
for (k in object) { | ||
cookies.push(k + '=' + object[k]); | ||
} | ||
return cookies.join(';'); | ||
} | ||
function stackTrace(err) { | ||
@@ -265,2 +278,9 @@ // From TraceKit: Opera 10 *destroys* its stacktrace property if you try to | ||
var data = cgiData(); | ||
if (typeof err.cookies === 'string') { | ||
data['HTTP_COOKIE'] = err.cookies; | ||
} else if (typeof err.cookies === 'object') { | ||
data['HTTP_COOKIE'] = encodeCookie(err.cookies); | ||
} | ||
var payload = { | ||
@@ -280,3 +300,4 @@ notifier: NOTIFIER, | ||
context: merge(self.context, err.context), | ||
cgi_data: cgiData() | ||
cgi_data: data, | ||
params: err.params | ||
}, | ||
@@ -283,0 +304,0 @@ server: { |
{ | ||
"name": "honeybadger-js", | ||
"description": "A JavaScript library for integrating apps with the Honeybadger Rails Error Notifier.", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"homepage": "https://github.com/honeybadger-io/honeybadger-js", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -38,3 +38,3 @@ # Honeybadger Client-Side Javascript Library | ||
``` | ||
npm install honeybadger-js --save-dev | ||
npm install honeybadger-js --save | ||
``` | ||
@@ -45,3 +45,3 @@ | ||
```sh | ||
bower install honeybadger --save-dev | ||
bower install honeybadger --save | ||
``` | ||
@@ -192,3 +192,5 @@ | ||
environment: 'production', | ||
project_root: 'https://www.example.com/' | ||
project_root: 'https://www.example.com/', | ||
params: { key: 'value' }, | ||
cookies: { key: 'value' } // May also be sent as a string in the document.cookie "foo=bar;bar=baz" format. | ||
}); | ||
@@ -310,4 +312,5 @@ ``` | ||
* context - The context object. | ||
* params - An object of request parameters. | ||
* cookies - An object of cookie key/values. May also be sent as a string in the document.cookie "foo=bar;bar=baz" format. | ||
--- | ||
@@ -392,2 +395,21 @@ | ||
#### Authentication | ||
Requests sent from Honeybadger servers to download sourcemaps and related-files include a secret token in the `Honeybadger-Token` header, which may be used to authenticate requests from Honeybadger. | ||
To find your `Honeybadger-Token` token, visit your project settings page in Honeybadger and click on the "Sourcemaps" tab. | ||
One exception is direct links from the Honeybadger UI (such as when displaying links in backtraces); these cannot be authenticated. | ||
## Sending cookies by default | ||
To automatically send cookies with all error reports, use the following `::beforeNotify` handler: | ||
```js | ||
Honeybadger.beforeNotify(function(err){ | ||
err.cookies = document.cookie; | ||
return true; | ||
}) | ||
``` | ||
## window.onerror | ||
@@ -406,3 +428,2 @@ | ||
## Contributing | ||
@@ -423,2 +444,1 @@ | ||
The Honeybadger gem is MIT licensed. See the [MIT-LICENSE](https://raw.github.com/honeybadger-io/honeybadger-js/master/MIT-LICENSE) file in this repository for details. | ||
@@ -246,2 +246,51 @@ describe('Honeybadger', function() { | ||
}); | ||
it('sends params', function() { | ||
Honeybadger.configure({ | ||
api_key: 'asdf' | ||
}); | ||
Honeybadger.notify("testing", { | ||
params: { | ||
foo: 'bar' | ||
} | ||
}); | ||
afterNotify(function() { | ||
expect(requests.length).toEqual(1); | ||
expect(requests[0].url).toMatch('notice%5Brequest%5D%5Bparams%5D%5Bfoo%5D=bar'); | ||
}); | ||
}); | ||
it('sends cookies as string', function() { | ||
Honeybadger.configure({ | ||
api_key: 'asdf' | ||
}); | ||
Honeybadger.notify("testing", { | ||
cookies: 'foo=bar' | ||
}); | ||
afterNotify(function() { | ||
expect(requests.length).toEqual(1); | ||
expect(requests[0].url).toMatch('notice%5Brequest%5D%5Bcgi_data%5D%5BHTTP_COOKIE%5D=foo%3Dbar'); | ||
}); | ||
}); | ||
it('sends cookies as object', function() { | ||
Honeybadger.configure({ | ||
api_key: 'asdf' | ||
}); | ||
Honeybadger.notify("testing", { | ||
cookies: { | ||
foo: 'bar' | ||
} | ||
}); | ||
afterNotify(function() { | ||
expect(requests.length).toEqual(1); | ||
expect(requests[0].url).toMatch('notice%5Brequest%5D%5Bcgi_data%5D%5BHTTP_COOKIE%5D=foo%3Dbar'); | ||
}); | ||
}); | ||
}); | ||
@@ -248,0 +297,0 @@ |
379039
9587
438