diff --git a/src/pages/api/errorLogger.js b/src/pages/api/errorLogger.js index 7f05c167b..158ce35b1 100644 --- a/src/pages/api/errorLogger.js +++ b/src/pages/api/errorLogger.js @@ -1,8 +1,8 @@ import { log } from "dbc-node-logger"; +import { incErrorCount } from "@/utils/errorCount"; const DELAY = 5000; let lastMessage = 0; -let errorCounter = 0; /** * POST unhandled client side errors to this endpoint @@ -28,7 +28,7 @@ export default async function handler(req, res) { } catch (e) { parsed = {}; } - errorCounter++; + incErrorCount(); log.error("CLIENT SIDE ERROR", { clientError: { @@ -43,13 +43,3 @@ export default async function handler(req, res) { res.status(200).json({ message: "OK" }); } } - -/** - * The howru endpoint can get a count here, - * which will let us create alerts, when count is above some threshold - */ -export function getClientSideErrorCount() { - let res = errorCounter; - errorCounter = 0; - return res; -} diff --git a/src/pages/api/howru.js b/src/pages/api/howru.js index d1a25a61b..7a51ee042 100644 --- a/src/pages/api/howru.js +++ b/src/pages/api/howru.js @@ -6,7 +6,6 @@ import { getServerSession } from "@dbcdk/login-nextjs/server"; import { getErrorCount, resetErrorCount } from "@/utils/errorCount"; import getConfig from "next/config"; import { log } from "dbc-node-logger"; -import { getClientSideErrorCount } from "./errorLogger"; const { serverRuntimeConfig } = getConfig(); const { maxError500Count } = serverRuntimeConfig; @@ -92,17 +91,6 @@ export default async function handler(req, res) { // push error500 object to results results.push(error500); - const clientErrors = getClientSideErrorCount(); - const clientErrorsOk = clientErrors < maxError500Count; - if (!clientErrorsOk) { - ok = false; - } - results.push({ - service: "client-errors", - count: clientErrors, - ok: clientErrorsOk, - }); - // Log the service names that cause howru to fail results .filter((service) => !service.ok) @@ -112,7 +100,7 @@ export default async function handler(req, res) { }); }); - const body = { ok, upSince, services: results, clientErrors }; + const body = { ok, upSince, services: results }; log.info("howru status", { howruStatus: { ok, upSince, body: JSON.stringify(body) },