Node.js Client 1.0.0 and 1.1.0 Release

Hello! Today we’ve published versions 1.0.0 and 1.1.0 of our Node.js client, raven-node.

Take a look at our 1.0.0-beta post for some background on the changes here. The most important part to know from that post is this:

The API has changed a bit, mostly to bring it in line with Raven.js, but also to support the new context tracking functionality and make common use cases easier. We’ve largely maintained backwards compatibility, but there are new recommended usage patterns. If you’ve used our browser JS client, this should feel familiar.

That post walks through most of those changes, and Version 1.0.0 is effectively the 1.0.0-beta version with a few fixes and one small API tweak, so everything described in the 1.0.0-beta post should be accurate with one exception. Automatic capturing of unhandled Promise rejections is now enabled by doing:

// new way - do it like this!
Raven.config('___DSN___', {
  captureUnhandledRejections: true
}).install();

instead of what we had in the Beta:

// old way - it doesn't work!
Raven.config('___DSN___').install({ unhandledRejection: true });

Version 1.1.0 builds on the context capabilities of 1.0.0 and adds breadcrumb support! You can now capture breadcrumbs just like in our browser JavaScript client, raven-js:

// Must be inside a Raven context to capture breadcrumbs
// Note that if you're using our Express middleware, we automatically wrap each request in its own context
Raven.context(function () {
  Raven.captureBreadcrumb({
    message: 'Received payment confirmation',
    category: 'payment',
    data: {
       amount: 312,
    }
  });
});

We currently support automatic breadcrumbs for console logs (and other console methods), http/https requests, and postgres queries. You can enable automatic breadcrumbs like this:

Raven.config('___DSN___', {
  autoBreadcrumbs: true
}).install();

or enable only http/https breadcrumbs like this:

Raven.config('___DSN___', {
  autoBreadcrumbs: {
    console: false,
    http: true,
    postgres: false
  }
}).install();

Unlike raven-js, automatic breadcrumb collection in Node is currently off by default. We’re planning to add support for more database drivers soon, and to enable automatic breadcrumbs by default next month in Version 2.0.

You can get the new version by doing:

npm install raven

or more explicitly:

npm install raven@1.1.1

Complete documentation and setup walkthroughs will be finished and posted soon, but feel free to start playing with this in the meantime. Please let us know here or in the issue tracker if you run into anything strange, confusing, or broken!

1 Like

Awesome! I just searched about for an hour to do this because I did not find it in the docs:

https://docs.sentry.io/clients/node/config/

I’m happy to do a pull-request somewhere, but I did not find the source of the docs easily.