Feat: News in the client app (#34392)

This commit is contained in:
Stuart Taylor
2018-11-29 12:12:15 +00:00
committed by Valeriy
parent 28798dc008
commit d327a5c36b
87 changed files with 2334 additions and 1403 deletions

View File

@@ -5,20 +5,30 @@ import {
unwrapHandledError
} from '../utils/create-handled-error.js';
const { ROLLBAR_APP_ID } = process.env;
import { rollbar } from '../../../config/secrets';
const rollbar = new Rollbar(ROLLBAR_APP_ID);
const { appId } = rollbar;
const reporter = new Rollbar(appId);
const log = debug('fcc:middlewares:error-reporter');
const errTemplate = ({message, ...restError}, req) => `
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}
${JSON.stringify(restError, null, 2)}
// raw
${JSON.stringify(error, null, 2)}
`;
};
export function reportError(err) {
return reporter.error(err.message, err);
}
export default function errrorReporter() {
if (process.env.NODE_ENV !== 'production' && process.env.ERROR_REPORTER) {
@@ -44,6 +54,7 @@ export default function errrorReporter() {
// logging the error provides us with more information,
// i.e isAuthenticatedUser, req.route
console.error(errTemplate(err, req));
return rollbar.error(err.message, err);
reportError(err);
return next(err);
};
}