From c63e6cebc816aedc57861947cef2d7f1b0ddb0ac Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Thu, 10 Jul 2025 12:40:47 +0700 Subject: [PATCH] fix(plugins/no-track): use hooks instead of modifying directly --- src/plugins/preinit/no-track/index.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/plugins/preinit/no-track/index.ts b/src/plugins/preinit/no-track/index.ts index 3131ad2..94a11cd 100644 --- a/src/plugins/preinit/no-track/index.ts +++ b/src/plugins/preinit/no-track/index.ts @@ -34,10 +34,14 @@ registerPlugin( unsubSU() // These functions by Discord attempt to call Sentry APIs that set __SENTRY__ - SentryUtils.profiledRootComponent = x => x - SentryUtils.addBreadcrumb = noop - SentryUtils.setTags = noop - SentryUtils.setUser = noop + instead( + SentryUtils, + 'profiledRootComponent', + args => args[0], + ) + instead(SentryUtils, 'addBreadcrumb', noop) + instead(SentryUtils, 'setTags', noop) + instead(SentryUtils, 'setUser', noop) }, ) @@ -58,10 +62,14 @@ registerPlugin( exports => { unsubSentryInst() - exports.ReactNavigationInstrumentation = class { - // https://docs.sentry.io/platforms/react-native/tracing/instrumentation/react-navigation/#initialization - registerNavigationContainer = noop - } + instead( + exports, + 'ReactNavigationInstrumentation', + function () { + // https://docs.sentry.io/platforms/react-native/tracing/instrumentation/react-navigation/#initialization + this.registerNavigationContainer = noop + }, + ) }, ) @@ -74,7 +82,7 @@ registerPlugin( writable: false, }) - cleanup(unsubSIU, unsubSentryInst) + cleanup(unsubSU, unsubSIU, unsubSentryInst) }, init({ cleanup, logger }) { // utils/AnalyticsUtils.tsx