chore: remove rollbar, bump deps

This commit is contained in:
Oliver Eyton-Williams
2020-03-24 10:43:51 +01:00
committed by Mrugesh Mohapatra
parent 87ae387ecb
commit 38e7369b92
3 changed files with 293 additions and 990 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,7 @@
"helmet-csp": "^2.9.3",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"loopback": "^3.26.0",
"loopback": "^3.27.0",
"loopback-boot": "^2.28.0",
"loopback-connector-mongodb": "^4.2.0",
"method-override": "^3.0.0",
@ -60,7 +60,6 @@
"redux-actions": "^2.6.5",
"redux-saga": "^0.16.0",
"reselect": "^3.0.1",
"rollbar": "^2.13.0",
"rss-parser": "^3.7.3",
"rx": "^4.1.0",
"shortid": "^2.2.15",
@ -69,13 +68,13 @@
"validator": "^9.4.1"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.6.4",
"@babel/node": "^7.6.3",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"@babel/register": "^7.9.0",
"adler32": "~0.1.7",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.9.0",

View File

@ -1,66 +0,0 @@
import debug from 'debug';
import Rollbar from 'rollbar';
import {
isHandledError,
unwrapHandledError
} from '../utils/create-handled-error.js';
import { rollbar } from '../../../config/secrets';
const { appId } = rollbar;
const reporter = new Rollbar(appId);
const log = debug('fcc:middlewares:error-reporter');
const errTemplate = (error, req) => {
const { message, stack } = error;
return `
Time: ${new Date(Date.now()).toISOString()}
Error: ${message}
Is authenticated user: ${!!req.user}
Route: ${JSON.stringify(req.route, null, 2)}
Stack: ${stack}
// raw
${JSON.stringify(error, null, 2)}
`;
};
export function reportError(err) {
return process.env.FREECODECAMP_NODE_ENV === 'production' &&
process.env.ERROR_REPORTER === 'true'
? reporter.error(err.message, err)
: console.error(err);
}
export default function errorReporter() {
if (
process.env.FREECODECAMP_NODE_ENV !== 'production' &&
process.env.ERROR_REPORTER === 'true'
) {
return (err, req, res, next) => {
console.error(errTemplate(err, req));
if (isHandledError(err)) {
// log out user messages in development
const handled = unwrapHandledError(err);
log(handled.message);
}
next(err);
};
}
return (err, req, res, next) => {
// handled errors do not need to be reported,
// they report a message and maybe redirect the user
// errors with status codes shouldn't be reported
// as they are usually user messages
if (isHandledError(err) || err.statusCode || err.status) {
return next(err);
}
// logging the error provides us with more information,
// i.e isAuthenticatedUser, req.route
console.error(errTemplate(err, req));
reportError(err);
return next(err);
};
}