Sails JS hook to log errors and stack traces in Sentry from within your Sails.js applications.
npm install sails-hook-sentry
- requires at least sails >= 0.11*
By default, configuration lives in sails.config.sentry
. The configuration key (sentry
) can be changed by setting sails.config.hooks['sails-hook-sentry'].configKey
.
// [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