aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/noTrack.ts
blob: 642d88c7e28a54a31b2aed73a245c2b5e88169a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import definePlugin from "../utils/types";
import { findByProps } from "../webpack";

const DO_NOTHING = () => void 0;

export default definePlugin({
    name: "NoTrack",
    description: "Disable Discord's tracking and crash reporting",
    author: "Vendicated",
    required: true,
    start() {
        findByProps("getSuperPropertiesBase64", "track").track = DO_NOTHING;
        findByProps("submitLiveCrashReport").submitLiveCrashReport = DO_NOTHING;
        findByProps("AnalyticsActionHandlers").AnalyticsActionHandlers.handleTrack = DO_NOTHING;

        const sentry = window.__SENTRY__;
        sentry.logger.disable();

        sentry.hub.addBreadcrumb = DO_NOTHING;
        sentry.hub.getClient().close(0);
        sentry.hub.getScope().clear();

        const c = console;
        for (const method in c) {
            if (c[method].__sentry_original__)
                c[method] = c[method].__sentry_original__;
            if (c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__?.__sentry_original__)
                c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__ = c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__.__sentry_original__;
        }
    }

});