this repo has no description
1import { ExtensionWebExports } from "@moonlight-mod/types";
2import { Patch, PatchReplaceType } from "@moonlight-mod/types";
3
4export const patches: Patch[] = [
5 {
6 find: "DSN:function",
7 replace: {
8 type: PatchReplaceType.Normal,
9 match: /default:function\(\){return .}/,
10 replacement: 'default:function(){return require("disableSentry_stub")()}'
11 }
12 },
13 {
14 find: "window.DiscordSentry.addBreadcrumb",
15 replace: {
16 type: PatchReplaceType.Normal,
17 match: /default:function\(\){return .}/,
18 replacement:
19 'default:function(){return (...args)=>{moonlight.getLogger("disableSentry").debug("Sentry calling addBreadcrumb passthrough:", ...args);}}'
20 }
21 },
22 {
23 find: "initSentry:function",
24 replace: {
25 type: PatchReplaceType.Normal,
26 match: /initSentry:function\(\){return .}/,
27 replacement: "default:function(){return ()=>{}}"
28 }
29 },
30 {
31 find: "window.DiscordErrors=",
32 replace: {
33 type: PatchReplaceType.Normal,
34 match: /uses_client_mods:\(0,.\.usesClientMods\)\(\)/,
35 replacement: "uses_client_mods:false"
36 }
37 }
38];
39
40export const webpackModules: ExtensionWebExports["webpackModules"] = {
41 stub: {
42 run: function (module, exports, require) {
43 const logger = moonlight.getLogger("disableSentry");
44
45 const keys = [
46 "setUser",
47 "clearUser",
48 "setTags",
49 "setExtra",
50 "captureException",
51 "captureCrash",
52 "captureMessage",
53 "addBreadcrumb"
54 ];
55
56 module.exports = () =>
57 new Proxy(
58 {},
59 {
60 get(target, prop, receiver) {
61 if (prop === "profiledRootComponent") {
62 return (arg: any) => arg;
63 } else if (prop === "crash") {
64 return () => {
65 throw Error("crash");
66 };
67 } else if (keys.includes(prop.toString())) {
68 return (...args: any[]) =>
69 logger.debug(`Sentry calling "${prop.toString()}":`, ...args);
70 } else {
71 return undefined;
72 }
73 }
74 }
75 );
76 }
77 }
78};