[BC-37] add Sentry to Foxy-Moxy

This commit is contained in:
Amber Schenck 2019-10-15 12:05:44 -07:00 committed by Patreon-Amber
parent b2eba9af95
commit c0b208cc67
2 changed files with 9 additions and 1 deletions

View file

@ -18,6 +18,7 @@
},
"homepage": "https://github.com/Patreon/foxy-moxy#readme",
"dependencies": {
"@sentry/node": "^5.7.1",
"canvas": "^2.0.1",
"chance": "^1.0.16",
"connect-datadog": "*",

View file

@ -3,7 +3,7 @@ const connectDatadog = require('connect-datadog')
const uuid = require('uuid/v4')
const sanitize = require('sanitize-filename')
const Canvas = require('canvas')
const Sentry = require('@sentry/node');
const Fox = require('./js/fox.js')
const renderFox = require('./js/render-fox.js')
@ -40,6 +40,10 @@ function getFox (req, res, version) {
const cacheTimeout = 60 * 60 * 24 * 30
const app = express()
app.use(connectDatadog({stat: 'foxy-moxy'}))
Sentry.init({ dsn: 'https://46660182a19d400f9775f441ac9bcf15@sentry.io/1780766' })
// The request handler must be the first middleware on the app
app.use(Sentry.Handlers.requestHandler())
app.get('/healthcheck', (req, res) => {
res.status(200).end()
@ -53,4 +57,7 @@ app.get('/2/:width/:seed', (req, res) => {
getFox(req, res)
})
// The error handler must be before any other error middleware and after all controllers
app.use(Sentry.Handlers.errorHandler())
module.exports = app