From a8b0ce6f0353f5c6642c26afe8e0e8e371a5766a Mon Sep 17 00:00:00 2001 From: V Date: Thu, 14 Dec 2023 01:29:57 +0100 Subject: [PATCH] fix(notrack): murder sentry --- src/webpack/patchWebpack.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index f131471bf..db47c875a 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -58,6 +58,9 @@ if (window[WEBPACK_CHUNK]) { // normally, this is populated via webpackGlobal.push, which we patch below. // However, Discord has their .m prepopulated. // Thus, we use this hack to immediately access their wreq.m and patch all already existing factories + // + // Update: Discord now has TWO webpack instances. Their normal one and sentry + // Sentry does not push chunks to the global at all, so this same patch now also handles their sentry modules Object.defineProperty(Function.prototype, "m", { set(v: any) { // When using react devtools or other extensions, we may also catch their webpack here. @@ -65,8 +68,6 @@ if (window[WEBPACK_CHUNK]) { if (new Error().stack?.includes("discord.com")) { logger.info("Found webpack module factory"); patchFactories(v); - - delete (Function.prototype as any).m; } Object.defineProperty(this, "m", { @@ -142,7 +143,7 @@ function patchFactories(factories: Record