generated from nhcarrigan/template
fix: filter third-party script errors from frontend telemetry
This commit is contained in:
@@ -49,6 +49,18 @@ const initialiseFrontendLogger = (): void => {
|
|||||||
? argument
|
? argument
|
||||||
: JSON.stringify(argument);
|
: JSON.stringify(argument);
|
||||||
}).join(" ");
|
}).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";
|
const context = "console.error";
|
||||||
post("/api/fe/error", { context, message });
|
post("/api/fe/error", { context, message });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user