fix: filter third-party script errors from frontend telemetry
CI / Lint, Build & Test (push) Successful in 1m14s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m56s

This commit is contained in:
2026-04-01 13:55:40 -07:00
committed by Naomi Carrigan
parent 133c81fefe
commit de5570b5fc
+12
View File
@@ -49,6 +49,18 @@ const initialiseFrontendLogger = (): void => {
? argument
: JSON.stringify(argument);
}).join(" ");
/*
* Ignore errors originating entirely from third-party scripts (e.g. AdSense).
* Stack frames from our own code reference elysium.nhcarrigan.com or localhost;
* if none are present but external URLs are, the error is not actionable.
*/
const hasExternalUrl = (/https?:\/\//u).test(message);
const hasOurDomain = message.includes("elysium.nhcarrigan.com");
const hasOwnFrame = hasOurDomain || message.includes("localhost");
if (hasExternalUrl && !hasOwnFrame) {
return;
}
const context = "console.error";
post("/api/fe/error", { context, message });
};