Comparing version 1.0.0 to 1.1.0
@@ -0,3 +1,33 @@ | ||
# 1.1.0 - 12/12/2016 | ||
- Added support for (automatic) breadcrumbs [See #240] | ||
- `Raven.captureBreadcrumb` manual method | ||
- `autoBreadcrumbs` config field to automatically capture breadcrumbs for: | ||
- console logs | ||
- http requests | ||
- postgres queries | ||
- Deprecate `captureQuery` [See #239] | ||
# 1.0.0 - 12/12/2016 | ||
- `Raven.config(...)` instead of `new raven.Client(...)` | ||
- `Raven.install()` instead of `client.patchGlobal()` | ||
- The callback to `Raven.captureException` now fires after transmission [See #217] | ||
- Added `captureUnhandledRejections` option for Promise rejections | ||
- Introduced contexts and associated `set/merge/getContext` methods [See #207] | ||
- Added `shouldSendCallback` config option and `set*Callback` methods [See #220] | ||
- Added `intercept()` method [See #225] | ||
- Backwards compatibility was mostly maintained, but lots of stuff was deprecated | ||
- We'll print console messages if you're doing anything the old way | ||
- We'll also print console messages in certain situations where behavior might be surprising, like if no DSN is configured | ||
- You can disable these alerts with `Raven.disableConsoleAlerts();` | ||
# 0.12.3 - 11/21/2016 | ||
* Replace `node-uuid` dependency with `uuid` [See #236] | ||
# 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 | ||
* Fix bug where `environment` option was not actually being transmitted to Sentry [See #185] | ||
# 0.12.0 - 8/1/2016 | ||
@@ -4,0 +34,0 @@ * Add `environment` config option and `setRelease` method [See #179] |
@@ -12,6 +12,11 @@ 'use strict'; | ||
var domain = require('domain'); | ||
var autoBreadcrumbs = require('./breadcrumbs'); | ||
var extend = utils.extend; | ||
function Raven() {} | ||
function Raven() { | ||
this.breadcrumbs = { | ||
record: this.captureBreadcrumb.bind(this) | ||
}; | ||
} | ||
@@ -42,2 +47,26 @@ nodeUtil.inherits(Raven, events.EventEmitter); | ||
// autoBreadcrumbs: true enables all, autoBreadcrumbs: false disables all | ||
// autoBreadcrumbs: { http: true } enables a single type | ||
// this procedure will ensure that this.autoBreadcrumbs is an object populated | ||
// with keys -> bools reflecting actual status of all breadcrumb types | ||
var autoBreadcrumbDefaults = { | ||
console: false, | ||
http: false, | ||
pg: false | ||
}; | ||
// default to 30, don't allow higher than 100 | ||
this.maxBreadcrumbs = Math.max(0, Math.min(options.maxBreadcrumbs || 30, 100)); | ||
this.autoBreadcrumbs = extend({}, autoBreadcrumbDefaults); | ||
if (typeof options.autoBreadcrumbs !== 'undefined') { | ||
for (var key in autoBreadcrumbDefaults) { | ||
if (autoBreadcrumbDefaults.hasOwnProperty(key)) { | ||
if (typeof options.autoBreadcrumbs === 'boolean') { | ||
this.autoBreadcrumbs[key] = options.autoBreadcrumbs; | ||
} else if (typeof options.autoBreadcrumbs[key] === 'boolean') { | ||
this.autoBreadcrumbs[key] = options.autoBreadcrumbs[key]; | ||
} | ||
} | ||
} | ||
} | ||
this.captureUnhandledRejections = options.captureUnhandledRejections; | ||
@@ -76,2 +105,4 @@ this.loggerName = options.logger || ''; | ||
install: function install(opts, cb) { | ||
if (this.installed) return this; | ||
if (typeof opts === 'function') { | ||
@@ -85,5 +116,28 @@ cb = opts; | ||
} | ||
for (var key in this.autoBreadcrumbs) { | ||
if (this.autoBreadcrumbs.hasOwnProperty(key)) { | ||
this.autoBreadcrumbs[key] && autoBreadcrumbs.instrument(key, this); | ||
} | ||
} | ||
this.installed = true; | ||
return this; | ||
}, | ||
uninstall: function uninstall() { | ||
if (!this.installed) return this; | ||
autoBreadcrumbs.restoreOriginals(); | ||
// todo: this works for tests for now, but isn't what we ultimately want to be doing | ||
process.removeAllListeners('uncaughtException'); | ||
process.removeAllListeners('unhandledRejection'); | ||
this.installed = false; | ||
return this; | ||
}, | ||
generateEventId: function generateEventId() { | ||
@@ -101,2 +155,3 @@ return uuid().replace(/-/g, ''); | ||
var domainContext = domain.active && domain.active.sentryContext || {}; | ||
@@ -106,2 +161,5 @@ kwargs.user = extend({}, this._globalContext.user, domainContext.user, kwargs.user); | ||
kwargs.extra = extend({}, this._globalContext.extra, domainContext.extra, kwargs.extra); | ||
kwargs.breadcrumbs = { | ||
values: domainContext.breadcrumbs || [] | ||
}; | ||
@@ -201,16 +259,2 @@ kwargs.modules = utils.getModules(); | ||
captureQuery: function captureQuery(query, engine, kwargs, cb) { | ||
if (!cb && typeof kwargs === 'function') { | ||
cb = kwargs; | ||
kwargs = {}; | ||
} else { | ||
kwargs = kwargs || {}; | ||
} | ||
var eventId = this.generateEventId(); | ||
this.process(eventId, parsers.parseQuery(query, engine, kwargs), cb); | ||
return eventId; | ||
}, | ||
/* The onErr param here is sort of ugly and won't typically be used | ||
@@ -246,3 +290,3 @@ * but it lets us write the requestHandler middleware in terms of this function. | ||
onErr = function (err) { | ||
self.captureException(err, wrapDomain.sentryContext); | ||
self.captureException(err); | ||
}; | ||
@@ -311,3 +355,11 @@ } | ||
getContext: function getContext() { | ||
return domain.active ? domain.active.sentryContext : this._globalContext; | ||
if (domain.active) { | ||
if (!domain.active.sentryContext) { | ||
domain.active.sentryContext = {}; | ||
utils.consoleAlert('sentry context not found on active domain'); | ||
} | ||
return domain.active.sentryContext; | ||
} | ||
utils.consoleAlert('getContext called without context; this may indicate incorrect setup - refer to docs on contexts'); | ||
return this._globalContext; | ||
}, | ||
@@ -370,6 +422,23 @@ | ||
}; | ||
}, | ||
captureBreadcrumb: function (breadcrumb) { | ||
// Avoid capturing global-scoped breadcrumbs before instrumentation finishes | ||
if (!this.installed) return; | ||
breadcrumb = extend({ | ||
timestamp: +new Date / 1000 | ||
}, breadcrumb); | ||
var currCtx = this.getContext(); | ||
if (!currCtx.breadcrumbs) currCtx.breadcrumbs = []; | ||
currCtx.breadcrumbs.push(breadcrumb); | ||
if (currCtx.breadcrumbs.length > this.maxBreadcrumbs) { | ||
currCtx.breadcrumbs.shift(); | ||
} | ||
this.setContext(currCtx); | ||
} | ||
}); | ||
// Deprecations | ||
@@ -382,7 +451,11 @@ extend(Raven.prototype, { | ||
captureError: function captureError() { | ||
utils.consoleAlert('captureError has been deprecated and will be removed in v2.0'); | ||
utils.consoleAlert('captureError has been deprecated and will be removed in v2.0; use captureException instead'); | ||
return this.captureException.apply(this, arguments); | ||
}, | ||
captureQuery: function captureQuery() { | ||
utils.consoleAlert('captureQuery has been deprecated and will be removed in v2.0'); | ||
return this; | ||
}, | ||
patchGlobal: function (cb) { | ||
utils.consoleAlert('patchGlobal has been deprecated and will be removed in v2.0'); | ||
utils.consoleAlert('patchGlobal has been deprecated and will be removed in v2.0; use install instead'); | ||
registerExceptionHandler(this, cb); | ||
@@ -389,0 +462,0 @@ return this; |
@@ -56,12 +56,2 @@ 'use strict'; | ||
module.exports.parseQuery = function parseQuery(query, engine, kwargs) { | ||
kwargs = kwargs || {}; | ||
kwargs.message = query; | ||
kwargs.query = { | ||
query: query, | ||
engine: engine | ||
}; | ||
return kwargs; | ||
}; | ||
module.exports.parseRequest = function parseRequest(req, kwargs) { | ||
@@ -68,0 +58,0 @@ kwargs = kwargs || {}; |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"repository": "git://github.com/getsentry/raven-node.git", | ||
@@ -24,2 +24,3 @@ "author": "Matt Robenolt <matt@ydekproductions.com>", | ||
"test": "NODE_ENV=test istanbul cover _mocha -- --reporter dot && NODE_ENV=test node_modules/coffee-script/bin/coffee ./test/run.coffee", | ||
"test-full": "npm run test && cd test/instrumentation && ./run.sh", | ||
"lint": "node_modules/eslint/bin/eslint.js ." | ||
@@ -26,0 +27,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
349905
46
1491
3