diff --git a/apps/docs/lib/sentry-filters.ts b/apps/docs/lib/sentry-filters.ts index 5f7ad5e7..028ca62a 100644 --- a/apps/docs/lib/sentry-filters.ts +++ b/apps/docs/lib/sentry-filters.ts @@ -31,6 +31,13 @@ const ignoreErrors: RegExp[] = [ // Chromium's LevelDB storage (used by extensions and embedding browsers) failing to create a // file on a full disk or a locked profile. This build doesn't use IndexedDB. /^Non-Error promise rejection captured with value: IO error: .*\.ldb: Unable to create writable file\b/, + // A host app or browser evaluating its own snippet; the only frame is :1:1. + /^ReferenceError: LIDNotifyId is not defined$/, + // Browser features or extensions requesting Picture-in-Picture without a user gesture. + /^NotAllowedError: The request is not triggered by a user activation\.$/, + // Android in-app browsers (XBrowser family) injecting autofill/CSS scripts that call their own + // missing bridge globals. + /^ReferenceError: (?:sw|x)browser is not defined$/, ]; export const sentryEventFilters = { allowUrls, ignoreErrors }; diff --git a/apps/docs/scripts/sentry-filters.test.mjs b/apps/docs/scripts/sentry-filters.test.mjs index f1b8c217..511a09b2 100644 --- a/apps/docs/scripts/sentry-filters.test.mjs +++ b/apps/docs/scripts/sentry-filters.test.mjs @@ -101,6 +101,73 @@ test("keeps other IO error rejections", () => { assert.equal(kept(exception("UnhandledRejection", message)), true); }); +test("drops a host script's undefined LIDNotifyId global", () => { + // The host evaluates the snippet, so the only frame is and allowUrls passes. + const evaluated = { filename: "", lineno: 1, colno: 1, in_app: true }; + assert.equal(kept(exception("ReferenceError", "LIDNotifyId is not defined", [evaluated])), false); +}); + +test("keeps other undefined globals from an evaluated script", () => { + const evaluated = { filename: "", lineno: 1, colno: 1, in_app: true }; + for (const value of ["LIDNotifyIdx is not defined", "docsSearch is not defined"]) { + assert.equal(kept(exception("ReferenceError", value, [evaluated])), true, value); + } +}); + +test("drops a Picture-in-Picture request made without a user gesture", () => { + // Browser features or extensions call it on the page's video; the only frame is native. + const native = { filename: "[native code]", function: "requestPictureInPicture", in_app: true }; + const value = "The request is not triggered by a user activation."; + assert.equal(kept(exception("NotAllowedError", value, [native])), false); +}); + +test("keeps other NotAllowedError rejections", () => { + const native = { filename: "[native code]", function: "requestFullscreen", in_app: true }; + const value = "Permission denied by the user."; + assert.equal(kept(exception("NotAllowedError", value, [native])), true); +}); + +test("drops XBrowser's injected autofill script calling its missing bridge global", () => { + // XBrowser-family browsers inject via evaluateJavascript; the throw site is , so + // allowUrls sees only Sentry's setTimeout wrapper in our chunk (DOCS-ENGINE-16). + const timerWrapper = { + filename: "app:///_next/static/chunks/3u-vo9sql_7c2.js", + function: "n", + lineno: 5, + colno: 14159, + in_app: true, + }; + const autofill = { + filename: "", + function: "execute_auto_fill", + lineno: 1, + colno: 226, + in_app: true, + }; + const event = exception("ReferenceError", "xbrowser is not defined", [timerWrapper, autofill]); + assert.equal(kept(event), false); +}); + +test("drops XBrowser's injected CSS script calling its missing bridge global", () => { + // Reaches global_handlers.onerror with only frames, so allowUrls passes + // (DOCS-ENGINE-17). + const frames = [ + { filename: "", lineno: 1, colno: 1669, in_app: true }, + { filename: "", function: "needInjectCss", lineno: 1, colno: 1410, in_app: true }, + ]; + assert.equal(kept(exception("ReferenceError", "swbrowser is not defined", frames)), false); +}); + +test("keeps other undefined *browser globals from an injected script", () => { + const frames = [ + { filename: "", lineno: 1, colno: 1669, in_app: true }, + { filename: "", function: "needInjectCss", lineno: 1, colno: 1410, in_app: true }, + ]; + for (const value of ["zzbrowser is not defined", "browser is not defined"]) { + assert.equal(kept(exception("ReferenceError", value, frames)), true, value); + } +}); + test("keeps errors thrown by this build's code", () => { const frames = [ourFrame]; assert.equal(