listepo / sails-hook-sentry

Sails hook for Sentry(raven-node)
10 stars 9 forks source link
javascript raven-node sails-hook sails-hook-sentry sentry

sails-hook-sentry

Sails JS hook to log errors and stack traces in Sentry from within your Sails.js applications.

npm version Dependency Status devDependency Status

Installation

npm install sails-hook-sentry

Usage

Configuration

By default, configuration lives in sails.config.sentry. The configuration key (sentry) can be changed by setting sails.config.hooks['sails-hook-sentry'].configKey.

Example

// [your-sails-app]/config/sentry.js
module.exports.sentry = {
  active: true,
  dsn: "{{ DSN }}",
  options: {
    logger: 'default',
    release: '1.0.0',
    environment: 'staging'
  }
};
// [your-sails-app]/api/controllers/UserController.js
/**
 * UserController
 *
 * @description :: Server-side logic for managing users
 * @help        :: See http://links.sailsjs.org/docs/controllers
 */

module.exports = {
  find: function(req, res) {
    sails.sentry.captureMessage("Another message");
    res.ok('ok');
  }
};

If you want to log 500 responses, add this to your responses/serverError.js

// log error with sentry hook
if(sails.sentry) sails.sentry.captureException(data);

sails.sentry alias for Raven client

More sails.sentry methods raven-node