From 13722b994bc6b2ef4f4a90b11ec333c96e7735d5 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 13 Dec 2025 22:43:02 +0700 Subject: [PATCH] fix(plugins/no-track): crash on 310205+ Discord updated Sentry and now Sentry attempts also to set __SENTRY__ each attempt it tries to get the value, so now we fake the carrier instead. --- src/plugins/preinit/no-track/index.ts | 42 ++++++++++++++++++++------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/plugins/preinit/no-track/index.ts b/src/plugins/preinit/no-track/index.ts index 74b526b..6c0d8da 100644 --- a/src/plugins/preinit/no-track/index.ts +++ b/src/plugins/preinit/no-track/index.ts @@ -5,13 +5,35 @@ import { instead } from '@revenge-mod/patcher' import { InternalPluginFlags, registerPlugin } from '@revenge-mod/plugins/_' import { PluginFlags } from '@revenge-mod/plugins/constants' import { noop } from '@revenge-mod/utils/callback' -import { getCurrentStack } from '@revenge-mod/utils/error' const cachedOnly = { cached: true, } -// TODO(plugins/no-track): Block Sentry native-side +const fakeSentryCarrier = new Proxy( + { + encodePolyfill: () => new Uint8Array(), + decodePolyfill: () => '', + version: '', + _versions: [] as PropertyKey[], + }, + { + get: (target, prop) => { + if (target._versions.includes(prop)) return target + if (target[prop as keyof typeof target]) + return target[prop as keyof typeof target] + }, + set: (target, prop, value) => { + if (prop === 'version') { + target._versions.push(value) + return (target.version = value) + } else return value + }, + }, +) + +const getFakeCarrier = () => fakeSentryCarrier + registerPlugin( { id: 'revenge.no-track', @@ -80,15 +102,15 @@ registerPlugin( cachedOnly, ) - if (__DEV__) + // If we hadn't modified the global + if ( + Object.getOwnPropertyDescriptor(globalThis, '__SENTRY__') + ?.configurable + ) Object.defineProperty(globalThis, '__SENTRY__', { - set: () => { - warnSetSentry(getCurrentStack()) - }, - }) - else - Object.defineProperty(globalThis, '__SENTRY__', { - writable: false, + configurable: false, + get: getFakeCarrier, + set: getFakeCarrier, }) cleanup(unsubSU, unsubSIU, unsubSentryInst)