Skip to content
This repository has been archived by the owner on Jun 8, 2018. It is now read-only.

listepo/sails-hook-sentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • 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