this repo has no description
1import { join } from "node:path";
2import { Module } from "node:module";
3import { BrowserWindow } from "electron";
4
5const logger = moonlightHost.getLogger("disableSentry");
6
7if (moonlightHost.asarPath !== "moonlightDesktop") {
8 try {
9 const hostSentryPath = require.resolve(
10 join(moonlightHost.asarPath, "node_modules", "@sentry", "electron")
11 );
12 require.cache[hostSentryPath] = new Module(
13 hostSentryPath,
14 require.cache[require.resolve(moonlightHost.asarPath)]
15 );
16 require.cache[hostSentryPath]!.exports = {
17 init: () => {},
18 captureException: () => {},
19 setTag: () => {},
20 setUser: () => {}
21 };
22 logger.debug("Stubbed Sentry host side!");
23 } catch (err) {
24 logger.error("Failed to stub Sentry host side:", err);
25 }
26}
27
28moonlightHost.events.on("window-created", (window: BrowserWindow) => {
29 window.webContents.session.webRequest.onBeforeRequest(
30 {
31 urls: [
32 "https://*.sentry.io/*",
33 "https://*.discord.com/error-reporting-proxy/*"
34 ]
35 },
36 function (details, callback) {
37 callback({ cancel: true });
38 }
39 );
40});