Skip to content

Commit

Permalink
fix(notrack): murder sentry
Browse files Browse the repository at this point in the history
Vendicated committed Dec 14, 2023
1 parent b329591 commit a8b0ce6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/webpack/patchWebpack.ts
Original file line number Diff line number Diff line change
@@ -58,15 +58,16 @@ 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.
// This ensures we actually got the right one
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<string | number, (module: { exports: a

// There are (at the time of writing) 11 modules exporting the window
// Make these non enumerable to improve webpack search performance
if (exports === window) {
if (exports === window && require.c) {
Object.defineProperty(require.c, id, {
value: require.c[id],
enumerable: false,

0 comments on commit a8b0ce6

Please sign in to comment.