bug #1490830: add sentry and capture errors

This commit is contained in:
Luke Crouch 2018-10-30 16:24:44 -05:00
Родитель fb8268c4e7
Коммит 01206b68d4
6 изменённых файлов: 109 добавлений и 1 удалений

Просмотреть файл

@ -58,3 +58,6 @@ HIBP_NOTIFY_TOKEN="unsafe-default-token-for-dev"
# Which locales to support; * = all locales in the locales/ dir
SUPPORTED_LOCALES="*"
# DSN for Sentry error and event capturing
SENTRY_DSN=https://{key}@sentry.prod.mozaws.net/408

Просмотреть файл

@ -35,6 +35,7 @@ const kEnvironmentVariables = [
"HIBP_THROTTLE_MAX_TRIES",
"HIBP_NOTIFY_TOKEN",
"DATABASE_URL",
"SENTRY_DSN",
"SERVER_URL",
"SUPPORTED_LOCALES",
"DELETE_UNVERIFIED_SUBSCRIBERS_TIMER",

Просмотреть файл

@ -2,6 +2,12 @@
const { negotiateLanguages, acceptedLanguages } = require("fluent-langneg");
const Sentry = require("@sentry/node");
const AppConstants = require("./app-constants");
Sentry.init({
dsn: AppConstants.SENTRY_DSN,
environment: AppConstants.NODE_ENV,
});
const { FluentError } = require("./locale-utils");
const mozlog = require("./log");
@ -53,6 +59,7 @@ function asyncMiddleware (fn) {
function logErrors (err, req, res, next) {
log.error("error", {stack: err.stack});
Sentry.captureException(err);
next(err);
}

92
package-lock.json сгенерированный
Просмотреть файл

@ -302,6 +302,63 @@
"integrity": "sha512-LAQ1d4OPfSJ/BMbI2DuizmYrrkD9JMaTdi2hQTlI53lQ4kRQPyZQRS4CYQ7O66bnBBnP/oYdRxbk++X0xuFU6A==",
"dev": true
},
"@sentry/core": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-4.2.3.tgz",
"integrity": "sha512-xo5rvksftnaEdnKbdokyfuqgMnuqw1DFp0lDboIFHlEBcQde/AdThEgLujJWmbVNI3Cg7g8/HvP65f7QBjKfOw==",
"requires": {
"@sentry/hub": "4.2.3",
"@sentry/minimal": "4.2.3",
"@sentry/types": "4.2.3",
"@sentry/utils": "4.2.3"
}
},
"@sentry/hub": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-4.2.3.tgz",
"integrity": "sha512-7Jc/wz3vybYm1RX2wk/4zAQS8fo3uxvXYBkRfpm3OmnGgTlwDEmJwtegeGWFqufxLl85brZ19V1KAdulmO206A==",
"requires": {
"@sentry/types": "4.2.3",
"@sentry/utils": "4.2.3"
}
},
"@sentry/minimal": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-4.2.3.tgz",
"integrity": "sha512-Hus7LUeJDGsYpT2RTe6bUjG7mHG9uQoyDmW6pYUMN2dhD+cP5cPoTIXO4yxokwgAeDa+GH2/UXoASWc4s2eA2w==",
"requires": {
"@sentry/hub": "4.2.3",
"@sentry/types": "4.2.3"
}
},
"@sentry/node": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/node/-/node-4.2.3.tgz",
"integrity": "sha512-15xiTO3CrBSEg4x6EdPYBwcw+fzQ6QjMw6pttdafgQLwOuX0xY5ry2u+qVuE0HXyz9kBx3RhwiVV/A4RJTbiuQ==",
"requires": {
"@sentry/core": "4.2.3",
"@sentry/hub": "4.2.3",
"@sentry/types": "4.2.3",
"@sentry/utils": "4.2.3",
"cookie": "0.3.1",
"lsmod": "1.0.0",
"md5": "2.2.1",
"stack-trace": "0.0.10"
}
},
"@sentry/types": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-4.2.3.tgz",
"integrity": "sha512-Z7laXlLtLSEXcKzgcD2caWPMTM8sAvR86rssYM5uYb3azC5PO0aAvuhjokkdv1+Ke1Bg7lkaNZamiCSyaH/9xg=="
},
"@sentry/utils": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-4.2.3.tgz",
"integrity": "sha512-D6+M1081wCwGp8adWV3KFOxrxFmVyjMJ45x6/TnYvXdgDyc+t28oil21FHeKhwjld9eMqgQ5Tf1OOvos1MNBQg==",
"requires": {
"@sentry/types": "4.2.3"
}
},
"@sindresorhus/is": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz",
@ -1552,6 +1609,11 @@
"integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=",
"dev": true
},
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chokidar": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz",
@ -1980,6 +2042,11 @@
}
}
},
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"crypto-random-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz",
@ -3853,7 +3920,10 @@
"full-icu": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/full-icu/-/full-icu-1.2.1.tgz",
"integrity": "sha512-E2s1b4GVbt8PyG+iaRN6ks8N0Oy2LOJz7SIMUwWWWx7Mr5Z08hKkfpkKQbOtOGqzkFpckDJHjjZ8qfigN2W86A=="
"integrity": "sha512-E2s1b4GVbt8PyG+iaRN6ks8N0Oy2LOJz7SIMUwWWWx7Mr5Z08hKkfpkKQbOtOGqzkFpckDJHjjZ8qfigN2W86A==",
"requires": {
"icu4c-data": "^0.60.2"
}
},
"function-bind": {
"version": "1.1.1",
@ -4501,6 +4571,11 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"icu4c-data": {
"version": "0.60.2",
"resolved": "https://registry.npmjs.org/icu4c-data/-/icu4c-data-0.60.2.tgz",
"integrity": "sha512-4ScORTYJPIDJRPtAkQWXfKqGk8u1ThOxFWCJ3jkq+rj/MU4cK6isCvhFiEjunivw1/bJ10LqNAaJ9pAK68DEZg=="
},
"ienoopen": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/ienoopen/-/ienoopen-1.0.0.tgz",
@ -6664,6 +6739,11 @@
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
"integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA=="
},
"lsmod": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lsmod/-/lsmod-1.0.0.tgz",
"integrity": "sha1-mgD3bco26yP6BTUK/htYXUKZ5ks="
},
"make-dir": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz",
@ -6784,6 +6864,16 @@
"integrity": "sha512-3Zs9P/0zzwTob2pdgT0CHZuMbnSUSp8MB1bddfm+HDmnFWHGT4jvEZRf+2RuPoa+cjdn/z25SEt5gFTqdhvJAg==",
"dev": true
},
"md5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
"integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
"requires": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
"is-buffer": "~1.1.1"
}
},
"mdast-util-compact": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.1.tgz",

Просмотреть файл

@ -7,6 +7,7 @@
"url": "https://github.com/mozilla/blurts-server/issues"
},
"dependencies": {
"@sentry/node": "^4.2.3",
"arg": "^2.0.0",
"basic-auth": "^2.0.0",
"body-parser": "^1.18.3",

Просмотреть файл

@ -1,6 +1,12 @@
"use strict";
// initialize Sentry ASAP to capture fatal startup errors
const Sentry = require("@sentry/node");
const AppConstants = require("./app-constants");
Sentry.init({
dsn: AppConstants.SENTRY_DSN,
environment: AppConstants.NODE_ENV,
});
const express = require("express");
const exphbs = require("express-handlebars");