Add sentry error tracking

This commit is contained in:
Tim Perry 2017-03-17 18:37:07 +01:00
parent 697779868e
commit 88d8112402
No known key found for this signature in database
GPG Key ID: 0DDE38AFD3AF94F0
6 changed files with 41 additions and 4 deletions

View File

@ -3,6 +3,8 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
- Add Sentry error tracking
## [5.6.0] - 2017-03-23 ## [5.6.0] - 2017-03-23
### Added ### Added

View File

@ -15,7 +15,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var Promise, _, actions, capitano, errors, events, plugins, resin, update; var Promise, Raven, _, actions, capitano, errors, events, plugins, resin, update;
Raven = require('raven');
Raven.disableConsoleAlerts();
Raven.config('https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239', {
captureUnhandledRejections: true,
release: require('../package.json').version
}).install();
_ = require('lodash'); _ = require('lodash');

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var chalk, errors, patterns; var Promise, Raven, captureException, chalk, errors, patterns;
chalk = require('chalk'); chalk = require('chalk');
@ -23,6 +23,12 @@ errors = require('resin-cli-errors');
patterns = require('./utils/patterns'); patterns = require('./utils/patterns');
Raven = require('raven');
Promise = require('bluebird');
captureException = Promise.promisify(Raven.captureException.bind(Raven));
exports.handle = function(error) { exports.handle = function(error) {
var message; var message;
message = errors.interpret(error); message = errors.interpret(error);
@ -33,5 +39,7 @@ exports.handle = function(error) {
message = error.stack; message = error.stack;
} }
patterns.printErrorMessage(message); patterns.printErrorMessage(message);
return process.exit(error.exitCode || 1); return captureException(error).timeout(1000)["catch"](function() {})["finally"](function() {
return process.exit(error.exitCode || 1);
});
}; };

View File

@ -14,6 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
### ###
Raven = require('raven')
Raven.disableConsoleAlerts()
Raven.config(
'https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239'
captureUnhandledRejections: true
release: require('../package.json').version
).install()
_ = require('lodash') _ = require('lodash')
Promise = require('bluebird') Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano')) capitano = Promise.promisifyAll(require('capitano'))

View File

@ -17,6 +17,10 @@ limitations under the License.
chalk = require('chalk') chalk = require('chalk')
errors = require('resin-cli-errors') errors = require('resin-cli-errors')
patterns = require('./utils/patterns') patterns = require('./utils/patterns')
Raven = require('raven')
Promise = require('bluebird')
captureException = Promise.promisify(Raven.captureException.bind(Raven))
exports.handle = (error) -> exports.handle = (error) ->
message = errors.interpret(error) message = errors.interpret(error)
@ -26,4 +30,9 @@ exports.handle = (error) ->
message = error.stack message = error.stack
patterns.printErrorMessage(message) patterns.printErrorMessage(message)
process.exit(error.exitCode or 1)
captureException(error)
.timeout(1000)
.catch(-> # Ignore any errors (from error logging, or timeouts)
).finally ->
process.exit(error.exitCode or 1)

View File

@ -54,6 +54,7 @@
"president": "^2.0.1", "president": "^2.0.1",
"prettyjson": "^1.1.3", "prettyjson": "^1.1.3",
"reconfix": "^0.0.3", "reconfix": "^0.0.3",
"raven": "^1.2.0",
"resin-cli-auth": "^1.0.0", "resin-cli-auth": "^1.0.0",
"resin-cli-errors": "^1.2.0", "resin-cli-errors": "^1.2.0",
"resin-cli-form": "^1.4.1", "resin-cli-form": "^1.4.1",