dont load sentry on dev env (#243)

* dont load sentry on dev env
---------

Co-authored-by: neil <neil@neils-MacBook-Pro.local>
This commit is contained in:
Neil 2023-03-01 13:05:42 +08:00 committed by GitHub
parent 32e53ee1ad
commit a837f100b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 37 deletions

View file

@ -14,20 +14,21 @@ import path from "path";
autoUpdater.logger = log;
log.info("App starting...");
Sentry.init({
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624",
debug: true,
transportOptions: {
maxQueueAgeDays: 30,
maxQueueCount: 30,
beforeSend: async () => {
const ol = await net.isOnline();
log.log("isOnline", ol);
return ol ? "send" : "queue";
if (app.isPackaged) {
Sentry.init({
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624",
debug: true,
transportOptions: {
maxQueueAgeDays: 30,
maxQueueCount: 30,
beforeSend: async () => {
const ol = await net.isOnline();
log.log("isOnline", ol);
return ol ? "send" : "queue";
}
}
}
});
});
}
const serveURL = serve({ directory: "." });
const port = process.env.PORT || 3000;
const allowDebug = !app.isPackaged || process.env.DEBUG_BUILD === "1";
@ -49,7 +50,6 @@ function createWindow() {
minHeight: 450,
minWidth: 500,
webPreferences: {
// enableRemoteModule: true,
contextIsolation: false,
nodeIntegration: true,
spellcheck: false,
@ -115,7 +115,7 @@ contextMenu({
});
function loadVite(port) {
mainWindow?.loadURL(`http://localhost:${port}`).catch((e) => {
mainWindow?.loadURL(`http://localhost:${port}?is-vite=true`).catch((e) => {
console.log("Error loading URL, retrying", e);
setTimeout(() => {
loadVite(port);

View file

@ -1,23 +1,19 @@
// const { contextBridge, ipcRenderer } = require("electron");
const { init } = require("@sentry/electron/renderer");
const SvelteSentry = require("@sentry/svelte");
const isVite = () => {
try {
return window.location.href.includes("is-vite");
} catch (error) {
return false;
}
};
// contextBridge.exposeInMainWorld("electron", {
// send: (channel, data) => {
// ipcRenderer.send(channel, data);
// },
// sendSync: (channel, data) => {
// ipcRenderer.sendSync(channel, data);
// },
// receive: (channel, func) => {
// ipcRenderer.on(channel, (event, ...args) => func(...args));
// }
// });
init(
{
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624",
debug: true
},
SvelteSentry.init
);
if (!isVite()) {
const { init } = window.require("@sentry/electron/renderer");
const SvelteSentry = window.require("@sentry/svelte");
init(
{
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624",
debug: true
},
SvelteSentry.init
);
}