Skip to content

A platform for community discussion. Free, open, simple.

DEV: Identify errors/deprecations triggered by browser extensions (#24820)

David Taylor4a6267651217
diff --git a/app/assets/javascripts/discourse/app/lib/source-identifier.js b/app/assets/javascripts/discourse/app/lib/source-identifier.js
index f27605c111f..bd64582bda1 100644
--- a/app/assets/javascripts/discourse/app/lib/source-identifier.js
+++ b/app/assets/javascripts/discourse/app/lib/source-identifier.js
@@ -2,6 +2,12 @@ import DEBUG from "@glimmer/env";
import PreloadStore from "discourse/lib/preload-store";
import getURL from "discourse-common/lib/get-url";
+const BROWSER_EXTENSION_PROTOCOLS = [
+ "moz-extension://",
+ "chrome-extension://",
+ "webkit-masked-url://",
+];
+
export default function identifySource(error) {
if (!error || !error.stack) {
try {
@@ -22,6 +28,12 @@ export default function identifySource(error) {
""
);
+ if (BROWSER_EXTENSION_PROTOCOLS.any((p) => stack.includes(p))) {
+ return {
+ type: "browser-extension",
+ };
+ }
+
const themeMatches = stack.match(/\/theme-javascripts\/[\w-]+\.js/g) || [];
for (const match of themeMatches) {
@@ -72,6 +84,8 @@ export function consolePrefix(error, source) {
return `[THEME ${source.id} '${source.name}']`;
} else if (source && source.type === "plugin") {
return `[PLUGIN ${source.name}]`;
+ } else if (source && source.type === "browser-extension") {
+ return "[BROWSER EXTENSION]";
}
return "";