This repository was archived by the owner on Jun 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·51 lines (45 loc) · 1.3 KB
/
index.js
File metadata and controls
executable file
·51 lines (45 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module.exports = function Sentry(sails) {
return {
/**
* Default configuration
*
* We do this in a function since the configuration key for
* the hook is itself configurable, so we can't just return
* an object.
*/
defaults: {
__configKey__: {
// Set autoreload to be active by default
active: true,
dsn: null,
options: {}
}
},
/**
* Initialize the hook
* @param {Function} cb Callback for when we're done initializing
* @return {Function} cb Callback for when we're done initializing
*/
initialize: function(cb) {
var settings = sails.config[this.configKey];
if (!settings.active) {
sails.log.verbose('Autoreload hook deactivated.');
return cb();
}
if (!settings.dsn) {
sails.log.verbose('DSN for Sentry is required.');
return cb();
}
var Raven = require('raven');
Raven.config(settings.dsn, settings.options).install();
sails.sentry = Raven;
// handles Bluebird's promises unhandled rejections
process.on('unhandledRejection', function(reason) {
console.error('Unhandled rejection:', reason);
Raven.captureException(reason);
});
// We're done initializing.
return cb();
}
};
};