Skip to content

Commit

Permalink
Revert to main
Browse files Browse the repository at this point in the history
  • Loading branch information
agreenspan24 committed Sep 8, 2020
1 parent 531e307 commit f5e3f97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ CONFIG_FILE.json
scratch/
cypress/screenshots
cypress/videos
/webpack/bundle.js
21 changes: 8 additions & 13 deletions src/lib/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import minilog from "minilog";
import { isClient } from "./is-client";
const Rollbar = require("rollbar");
const rollbar = require("rollbar");
let logInstance = null;

if (isClient()) {
Expand All @@ -15,18 +15,13 @@ if (isClient()) {
existingErrorLogger.call(...errObj);
};
} else {
let rollbar = null;

let enableRollbar = false;
if (
process.env.NODE_ENV === "production" &&
process.env.ROLLBAR_ACCESS_TOKEN
) {
rollbar = new Rollbar({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true,
endpoint: "https://api.rollbar.com/api/1/item"
});
enableRollbar = true;
rollbar.init(process.env.ROLLBAR_ACCESS_TOKEN);
}

minilog.suggest.deny(
Expand All @@ -42,13 +37,13 @@ if (isClient()) {
logInstance = minilog("backend");
const existingErrorLogger = logInstance.error;
logInstance.error = err => {
if (rollbar) {
if (enableRollbar) {
if (typeof err === "object") {
rollbar.error(err);
rollbar.handleError(err);
} else if (typeof err === "string") {
rollbar.log(err);
rollbar.reportMessage(err);
} else {
rollbar.log("Got backend error with no error message");
rollbar.reportMessage("Got backend error with no error message");
}
}

Expand Down
11 changes: 0 additions & 11 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { seedZipCodes } from "./seeds/seed-zip-codes";
import { setupUserNotificationObservers } from "./notifications";
import { twiml } from "twilio";
import { existsSync } from "fs";
import Rollbar from "rollbar";
import { rawAllMethods } from "../extensions/contact-loaders";

process.on("uncaughtException", ex => {
Expand Down Expand Up @@ -97,16 +96,6 @@ if (process.env.SIMULATE_DELAY_MILLIS) {
});
}

if (process.env.NODE_ENV === "production" && process.env.ROLLBAR_ACCESS_TOKEN) {
const rollbar = new Rollbar({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true
});

app.use(rollbar.errorHandler());
}

// give contact loaders a chance
const configuredIngestMethods = rawAllMethods();
Object.keys(configuredIngestMethods).forEach(ingestMethodName => {
Expand Down

0 comments on commit f5e3f97

Please sign in to comment.