sails-hook-sentryd
v1.0.6
Published
Sails hook for Sentry (raven-node). Reworked
Downloads
2
Maintainers
Readme
sails-hook-sentry
Sails JS hook to log errors and stack traces in Sentry from within your Sails.js applications.
Installation
npm install sails-hook-sentry
Usage
- requires at least sails >= 0.11*
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