Comparing version 2.3.0 to 2.4.0
121
History.md
@@ -1,3 +0,10 @@ | ||
# 2.3.0 - 12/11/2017 | ||
# Changelog | ||
## 2.4.0 - 2018-01-24 | ||
- feat: Sensible non-Error exception serializer (#416) | ||
- fix: workaround for express.js 'host' deprecation message (#413) | ||
## 2.3.0 - 12/11/2017 | ||
- fix: attach remaining non-enumerables to req [See #387] | ||
@@ -12,7 +19,7 @@ - feat: Allow to configure stacktrace for captureMessage calls [See #388] | ||
# 2.2.1 - 10/02/2017 | ||
## 2.2.1 - 10/02/2017 | ||
- Remove unintentional memwatch-next dependency | ||
# 2.2.0 - 10/02/2017 | ||
## 2.2.0 - 10/02/2017 | ||
- Fixed all Node v8 tests to ensure everything is working correctly [See #366] | ||
@@ -27,9 +34,9 @@ - Raven now uses Prettier to format it's code [See #364] | ||
# 2.1.2 - 8/16/2017 | ||
## 2.1.2 - 8/16/2017 | ||
- Remove errant large file that accidentally got published in 2.1.1. [See #361] | ||
# 2.1.1 - 7/27/2017 | ||
## 2.1.1 - 7/27/2017 | ||
- Fix issue where HTTP request was duplicated as `req` (and dropped by Sentry server). [See #340] | ||
# 2.1.0 - 6/20/2017 | ||
## 2.1.0 - 6/20/2017 | ||
- Truncate long lines in surrounding source to avoid sending large amounts of minified code [See #329] | ||
@@ -39,9 +46,9 @@ - Refactor automatic breadcrumb instrumentation of modules to accommodate compilation tools [See #322] | ||
# 2.0.2 - 5/24/2017 | ||
## 2.0.2 - 5/24/2017 | ||
- Fix issue with sending empty request details when no request is present [See #324] | ||
# 2.0.1 - 5/16/2017 | ||
## 2.0.1 - 5/16/2017 | ||
- Fix memory explosion when parsing stack for large files [See #320] | ||
# 2.0.0 - 5/10/2017 | ||
## 2.0.0 - 5/10/2017 | ||
- Properly surface errors to preserve process exit conditions [See #308, #257] | ||
@@ -61,15 +68,15 @@ - Node processes with raven will now exit in exactly the same situations as if raven were not present | ||
# 1.1.6, 1.2.1 - 4/7/2017 | ||
## 1.1.6, 1.2.1 - 4/7/2017 | ||
- Fix memory leak in `consoleAlert` (and thus, if not disabled, in `captureException`) [See #300] | ||
# 1.2.0 - 3/16/2017 | ||
## 1.2.0 - 3/16/2017 | ||
- Add sampleRate config option [See #292] | ||
# 1.1.5 - 3/16/2017 | ||
## 1.1.5 - 3/16/2017 | ||
- Fix memory leak in http autoBreadcrumb instrumentation [See #296] | ||
# 1.1.4 - 3/6/2017 | ||
## 1.1.4 - 3/6/2017 | ||
- Use `util.format` to get message string in `console` instrumentation [See #289] | ||
# 1.1.3 - 2/27/2017 | ||
## 1.1.3 - 2/27/2017 | ||
- Add `parseUser` option to control user parsing behavior [See #274] | ||
@@ -79,3 +86,3 @@ - Make http instrumentation use `req.emit` instead of response event handler [See #276] | ||
# 1.1.2 - 2/8/2017 | ||
## 1.1.2 - 2/8/2017 | ||
- Send kwargs to `shouldSendCallback` [See #251] | ||
@@ -87,6 +94,6 @@ - Capture breadcrumbs from global context [See #267] | ||
# 1.1.1 and 1.0.1 - 12/13/2016 | ||
## 1.1.1 and 1.0.1 - 12/13/2016 | ||
- Fix middleware backwards compatibility [See #246] | ||
# 1.1.0 - 12/12/2016 | ||
## 1.1.0 - 12/12/2016 | ||
- Added support for (automatic) breadcrumbs [See #240] | ||
@@ -100,3 +107,3 @@ - `Raven.captureBreadcrumb` manual method | ||
# 1.0.0 - 12/12/2016 | ||
## 1.0.0 - 12/12/2016 | ||
- `Raven.config(...)` instead of `new raven.Client(...)` | ||
@@ -114,13 +121,13 @@ - `Raven.install()` instead of `client.patchGlobal()` | ||
# 0.12.3 - 11/21/2016 | ||
## 0.12.3 - 11/21/2016 | ||
* Replace `node-uuid` dependency with `uuid` [See #236] | ||
# 0.12.2 - 11/17/2016 | ||
## 0.12.2 - 11/17/2016 | ||
* Add column number to stack frames [See #235] | ||
* Check that `require.main.filename` is defined [See #233] | ||
# 0.12.1 - 8/4/2016 | ||
## 0.12.1 - 8/4/2016 | ||
* Fix bug where `environment` option was not actually being transmitted to Sentry [See #185] | ||
# 0.12.0 - 8/1/2016 | ||
## 0.12.0 - 8/1/2016 | ||
* Add `environment` config option and `setRelease` method [See #179] | ||
@@ -131,11 +138,11 @@ * No longer passes `process.env` values [See #181] | ||
# 0.11.0 - 5/5/2016 | ||
## 0.11.0 - 5/5/2016 | ||
* `captureError` renamed to `captureException` to match raven-js (alias exists for backwards compat) | ||
* `parsers.parseError` now coerces Error type to string. [See #155] | ||
# 0.10.0 - 1/24/2016 | ||
## 0.10.0 - 1/24/2016 | ||
* Now supports global context for extra data, tags, user [See #141] | ||
* Added `setUserContext`, `setExtraContext`, `setTagsContext` | ||
# 0.9.0 - 11/23/2015 | ||
## 0.9.0 - 11/23/2015 | ||
* Always coerce req.body to string. [See 2061d4efbf269c5e2096f2b7b55f5af2249c4aa7] | ||
@@ -146,6 +153,6 @@ * Allow passing options to HTTP transports. [See #123] | ||
# 0.8.1 - 06/15/2015 | ||
## 0.8.1 - 06/15/2015 | ||
* Fixed a missing `domain` import in the Express/Connect middleware [See #120] | ||
# 0.8.0 - 06/15/2015 | ||
## 0.8.0 - 06/15/2015 | ||
* Drop support for node 0.6 | ||
@@ -159,3 +166,3 @@ * Remove `SENTRY_SITE` environment variable usage | ||
# 0.7.3 - 03/05/2015 | ||
## 0.7.3 - 03/05/2015 | ||
* When calling `captureError` without an Error, generate a fake `Error` object to pull stacktrace from. [See #87] | ||
@@ -169,9 +176,9 @@ * Prevent `patchGlobal` from causing recursion [See #84] | ||
# 0.7.2 - 09/09/2014 | ||
## 0.7.2 - 09/09/2014 | ||
* Added `dataCallback` option to Client configuration. See: https://github.com/getsentry/raven-node#pre-processing-data | ||
# 0.7.1 - 08/24/2014 | ||
## 0.7.1 - 08/24/2014 | ||
* Fixed package.json to not install junk from `optionalDependencies`. TIL `optionalDependencies` are still installed. [See #89] | ||
# 0.7.0 - 06/24/2014 | ||
## 0.7.0 - 06/24/2014 | ||
* Moved from mattrobenolt/raven-node into getsentry/raven-node | ||
@@ -182,7 +189,7 @@ * Bumped to sentry protocol version 5 | ||
# 0.6.3 - 04/02/2014 | ||
## 0.6.3 - 04/02/2014 | ||
* Fix another issue that was breaking when running Raven from the REPL [See #66] | ||
* Add additional meta data on the error callbacks [See #67 #73] | ||
# 0.6.2 - 02/14/2014 | ||
## 0.6.2 - 02/14/2014 | ||
* Allow overriding the logger name for an individual event | ||
@@ -192,3 +199,3 @@ * Update lsmod to not break when running Raven from the REPL | ||
# 0.6.1 - 01/23/2014 | ||
## 0.6.1 - 01/23/2014 | ||
* Use lsmod for getting the list of installed modules [See #55] | ||
@@ -198,3 +205,3 @@ * Parse cookies on the http request always [See #56] | ||
# 0.6.0 - 11/9/2013 | ||
## 0.6.0 - 11/9/2013 | ||
* Updated sentry protocol to version 4 (Requires Sentry 6.0+ now) | ||
@@ -204,22 +211,22 @@ * Module names now include the full path | ||
# 0.5.6 - 11/8/2013 | ||
## 0.5.6 - 11/8/2013 | ||
* Include module and function name in stacktrace culprit | ||
# 0.5.5 - 11/8/2013 | ||
## 0.5.5 - 11/8/2013 | ||
* Only record exceptions for 500 status codes from Connect middleware | ||
# 0.5.4 - 10/13/2013 | ||
## 0.5.4 - 10/13/2013 | ||
* Fix DSN parser when using Sentry at a non-root URL, thanks @rcoup [See #44] | ||
# 0.5.3 - 10/4/2013 | ||
## 0.5.3 - 10/4/2013 | ||
* Bump raw-stacktrace version | ||
# 0.5.2 - 9/10/2013 | ||
## 0.5.2 - 9/10/2013 | ||
* Fix compatibilities with CoffeeScript [Fixes #47] [Fixes #50] | ||
* Doesnt chose on circular references | ||
# 0.5.1 - 5/1/2013 | ||
## 0.5.1 - 5/1/2013 | ||
* Add support for third party transports, thanks @crankycoder | ||
# 0.5.0 - 4/8/2013 | ||
## 0.5.0 - 4/8/2013 | ||
* Remove NODE_ENV entirely, fixes many issues since people have different opinions on wtf this means | ||
@@ -231,20 +238,20 @@ * Several fixes in collecting a better stack trace, thanks @azylman | ||
# 0.4.7 - 1/13/2013 | ||
## 0.4.7 - 1/13/2013 | ||
* Actually disable when NODE_ENV does not equal 'production' [Fixes #25] | ||
# 0.4.6 - 1/13/2013 | ||
## 0.4.6 - 1/13/2013 | ||
* Added `platform=node` to payload for Sentry 5.1 | ||
# 0.4.5 - 12/05/2012 | ||
## 0.4.5 - 12/05/2012 | ||
* Resolve `node_modules` path properly [Fixes #23] | ||
# 0.4.4 - 11/10/2012 | ||
## 0.4.4 - 11/10/2012 | ||
* Prevent 'error' event from bubbling up due to no listeners [See #22] | ||
* Augment 'error' event emitter with an actual Error object [See #22] | ||
# 0.4.3 - 10/02/2012 | ||
## 0.4.3 - 10/02/2012 | ||
* Allow a callback to be given to `patchGlobal()` [Fixes #19] | ||
* Removed old `patch_global()` alias | ||
# 0.4.2 - 9/29/2012 | ||
## 0.4.2 - 9/29/2012 | ||
* Added test coverage to `patchGlobal()` | ||
@@ -254,9 +261,9 @@ * Quit using my own deprecated `get_ident()` method inside `patchGlobal` | ||
# 0.4.1 - 9/3/2012 | ||
## 0.4.1 - 9/3/2012 | ||
* patchGlobal() was actually broken. :( Thanks @ligthyear [Fixes #17] | ||
# 0.4.0 - 8/14/2012 | ||
## 0.4.0 - 8/14/2012 | ||
* Silence and disable Raven/Sentry when using a non-existent or falsey DSN value | ||
# 0.3.0 - 6/23/2012 | ||
## 0.3.0 - 6/23/2012 | ||
* Separate transports out into their own module for portability | ||
@@ -266,16 +273,16 @@ * Added UDP transport [Fixes #10] | ||
# 0.2.4 - 6/16/2012 | ||
## 0.2.4 - 6/16/2012 | ||
* Added parsing DSNs with non-standard port. [Fixes #4] | ||
* Added BSD license | ||
# 0.2.3 - 3/30/2012 | ||
## 0.2.3 - 3/30/2012 | ||
* Prevent any potentially odd stack traces from causing Raven to crash. [Fixes #2] | ||
# 0.2.2 - 3/22/2012 | ||
## 0.2.2 - 3/22/2012 | ||
* raven.Client now emits `logged` and `error` events. | ||
# 0.2.1 - 3/22/2012 | ||
## 0.2.1 - 3/22/2012 | ||
* Fixed connect/express middleware, thanks Almad! | ||
# 0.2.0 - 3/18/2012 | ||
## 0.2.0 - 3/18/2012 | ||
* Renamed all methods to follow `client.capture*()` pattern. (Sorry if you were already using it!) | ||
@@ -289,3 +296,3 @@ * All `npm` installed modules are shoved into Sentry for debugging | ||
# 0.1.0 - 3/17/2012 | ||
## 0.1.0 - 3/17/2012 | ||
* Initial release |
@@ -12,2 +12,3 @@ 'use strict'; | ||
var domain = require('domain'); | ||
var md5 = require('md5'); | ||
@@ -359,9 +360,2 @@ var instrumentor = require('./instrumentation/instrumentor'); | ||
captureException: function captureException(err, kwargs, cb) { | ||
if (!(err instanceof Error)) { | ||
// This handles when someone does: | ||
// throw "something awesome"; | ||
// We synthesize an Error here so we can extract a (rough) stack trace. | ||
err = new Error(err); | ||
} | ||
if (!cb && typeof kwargs === 'function') { | ||
@@ -374,2 +368,28 @@ cb = kwargs; | ||
if (!(err instanceof Error)) { | ||
if (utils.isPlainObject(err)) { | ||
// This will allow us to group events based on top-level keys | ||
// which is much better than creating new group when any key/value change | ||
var keys = Object.keys(err).sort(); | ||
var hash = md5(keys); | ||
var message = | ||
'Non-Error exception captured with keys: ' + | ||
utils.serializeKeysForMessage(keys); | ||
var serializedException = utils.serializeException(err); | ||
kwargs.message = message; | ||
kwargs.fingerprint = [hash]; | ||
kwargs.extra = { | ||
__serialized__: serializedException | ||
}; | ||
err = new Error(message); | ||
} else { | ||
// This handles when someone does: | ||
// throw "something awesome"; | ||
// We synthesize an Error here so we can extract a (rough) stack trace. | ||
err = new Error(err); | ||
} | ||
} | ||
var self = this; | ||
@@ -586,5 +606,5 @@ var eventId = this.generateEventId(); | ||
var request = extend.apply(null, sources); | ||
var nonEnumberables = [ | ||
var nonEnumerables = [ | ||
'headers', | ||
'host', | ||
'hostname', | ||
'ip', | ||
@@ -598,3 +618,3 @@ 'method', | ||
nonEnumberables.forEach(function(key) { | ||
nonEnumerables.forEach(function(key) { | ||
sources.forEach(function(source) { | ||
@@ -605,2 +625,14 @@ if (source[key]) request[key] = source[key]; | ||
/** | ||
* Check for 'host' *only* after we checked for 'hostname' first. | ||
* This way we can avoid the noise coming from Express deprecation warning | ||
* https://github.com/expressjs/express/blob/b97faff6e2aa4d34d79485fe4331cb0eec13ad57/lib/request.js#L450-L452 | ||
* REF: https://github.com/getsentry/raven-node/issues/96#issuecomment-354748884 | ||
**/ | ||
if (!request.hasOwnProperty('hostname')) { | ||
sources.forEach(function(source) { | ||
if (source.host) request.host = source.host; | ||
}); | ||
} | ||
return request; | ||
@@ -607,0 +639,0 @@ } |
103
lib/utils.js
@@ -9,2 +9,3 @@ 'use strict'; | ||
var stacktrace = require('stack-trace'); | ||
var stringify = require('../vendor/json-stringify-safe'); | ||
@@ -20,2 +21,104 @@ var ravenVersion = require('../package.json').version; | ||
// Default Node.js REPL depth | ||
var MAX_SERIALIZE_EXCEPTION_DEPTH = 3; | ||
// 50kB, as 100kB is max payload size, so half sounds reasonable | ||
var MAX_SERIALIZE_EXCEPTION_SIZE = 50 * 1024; | ||
var MAX_SERIALIZE_KEYS_LENGTH = 40; | ||
function utf8Length(value) { | ||
return ~-encodeURI(value).split(/%..|./).length; | ||
} | ||
function jsonSize(value) { | ||
return utf8Length(JSON.stringify(value)); | ||
} | ||
function isPlainObject(what) { | ||
return Object.prototype.toString.call(what) === '[object Object]'; | ||
} | ||
module.exports.isPlainObject = isPlainObject; | ||
function serializeValue(value) { | ||
var maxLength = 40; | ||
if (typeof value === 'string') { | ||
return value.length <= maxLength ? value : value.substr(0, maxLength - 1) + '\u2026'; | ||
} else if ( | ||
typeof value === 'number' || | ||
typeof value === 'boolean' || | ||
typeof value === 'undefined' | ||
) { | ||
return value; | ||
} | ||
var type = Object.prototype.toString.call(value); | ||
// Node.js REPL notation | ||
if (type === '[object Object]') return '[Object]'; | ||
if (type === '[object Array]') return '[Array]'; | ||
if (type === '[object Function]') | ||
return value.name ? '[Function: ' + value.name + ']' : '[Function]'; | ||
return value; | ||
} | ||
function serializeObject(value, depth) { | ||
if (depth === 0) return serializeValue(value); | ||
if (isPlainObject(value)) { | ||
return Object.keys(value).reduce(function(acc, key) { | ||
acc[key] = serializeObject(value[key], depth - 1); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(value)) { | ||
return value.map(function(val) { | ||
return serializeObject(val, depth - 1); | ||
}); | ||
} | ||
return serializeValue(value); | ||
} | ||
function serializeException(ex, depth, maxSize) { | ||
if (!isPlainObject(ex)) return ex; | ||
depth = typeof depth !== 'number' ? MAX_SERIALIZE_EXCEPTION_DEPTH : depth; | ||
maxSize = typeof depth !== 'number' ? MAX_SERIALIZE_EXCEPTION_SIZE : maxSize; | ||
var serialized = serializeObject(ex, depth); | ||
if (jsonSize(stringify(serialized)) > maxSize) { | ||
return serializeException(ex, depth - 1); | ||
} | ||
return serialized; | ||
} | ||
module.exports.serializeException = serializeException; | ||
function serializeKeysForMessage(keys, maxLength) { | ||
if (typeof keys === 'number' || typeof keys === 'string') return keys.toString(); | ||
if (!Array.isArray(keys)) return ''; | ||
keys = keys.filter(function(key) { | ||
return typeof key === 'string'; | ||
}); | ||
if (keys.length === 0) return '[object has no keys]'; | ||
maxLength = typeof maxLength !== 'number' ? MAX_SERIALIZE_KEYS_LENGTH : maxLength; | ||
if (keys[0].length >= maxLength) return keys[0]; | ||
for (var usedKeys = keys.length; usedKeys > 0; usedKeys--) { | ||
var serialized = keys.slice(0, usedKeys).join(', '); | ||
if (serialized.length > maxLength) continue; | ||
if (usedKeys === keys.length) return serialized; | ||
return serialized + '\u2026'; | ||
} | ||
return ''; | ||
} | ||
module.exports.serializeKeysForMessage = serializeKeysForMessage; | ||
module.exports.disableConsoleAlerts = function disableConsoleAlerts() { | ||
@@ -22,0 +125,0 @@ consoleAlerts = false; |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"repository": "git://github.com/getsentry/raven-node.git", | ||
@@ -36,2 +36,3 @@ "license": "BSD-2-Clause", | ||
"lsmod": "1.0.0", | ||
"md5": "^2.2.1", | ||
"stack-trace": "0.0.9", | ||
@@ -38,0 +39,0 @@ "timed-out": "4.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
65162
1349
3
6
+ Addedmd5@^2.2.1
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedmd5@2.3.0(transitive)