From 8fe46fd8e8b345931a736db9dfcd5b7b5952fb1e Mon Sep 17 00:00:00 2001 From: tsukumi Date: Wed, 15 Jan 2025 08:53:55 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=E9=96=8B=E7=99=BA=E7=92=B0=E5=A2=83?= =?UTF-8?q?=E3=81=A7=E3=81=AF=20Sentry=20=E3=82=92=E7=84=A1=E5=8A=B9?= =?UTF-8?q?=E5=8C=96=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 開発環境ではエラーが起こること前提でテストしたりもするため、それらが一々 Issue に送られていたら対処にキリがなくなる あくまで本番環境で稼働しているソフトウェアのエラーを把握することが目的なので、開発環境ではエラーを送らないようにした --- src/backend/electron/main.ts | 15 +++++++----- src/main.ts | 47 +++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/backend/electron/main.ts b/src/backend/electron/main.ts index 391f2833..eadf32bf 100644 --- a/src/backend/electron/main.ts +++ b/src/backend/electron/main.ts @@ -30,6 +30,7 @@ import { registerIpcMainHandle, ipcMainSendProxy, IpcMainHandle } from "./ipc"; import { getConfigManager } from "./electronConfig"; import { getEngineAndVvppController } from "./engineAndVvppController"; import { writeFileSafely } from "./fileHelper"; +import { isProduction } from "@/helpers/platform"; import { failure, success } from "@/type/result"; import { AssetTextFileNames } from "@/type/staticResources"; import { @@ -89,14 +90,16 @@ if (!isDevelopment) { configMigration014({ fixedUserDataDir, beforeUserDataDir }); // 以前のファイルがあれば持ってくる } -// Sentry によるエラートラッキングを開始 +// Sentry によるエラートラッキングを開始 (production 環境のみ有効) // app.setPath("userData") を設定した後に呼ぶ必要がある // ref: https://docs.sentry.io/platforms/javascript/guides/electron/ -Sentry.init({ - dsn: "https://ab3b3a5b0e9d1c90dae483f740dbc78b@o4508551725383680.ingest.us.sentry.io/4508555292901376", - release: `AivisSpeech@${app.getVersion() === "999.999.999" ? "latest" : app.getVersion()}`, - environment: import.meta.env.MODE, -}); +if (isProduction) { + Sentry.init({ + dsn: "https://ab3b3a5b0e9d1c90dae483f740dbc78b@o4508551725383680.ingest.us.sentry.io/4508555292901376", + release: `AivisSpeech@${app.getVersion() === "999.999.999" ? "latest" : app.getVersion()}`, + environment: "production", + }); +} log.initialize({ preload: false }); // silly 以上のログをコンソールに出力 diff --git a/src/main.ts b/src/main.ts index 999ac454..86aaca33 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,7 @@ import { ipcMessageReceiver } from "./plugins/ipcMessageReceiverPlugin"; import { hotkeyPlugin } from "./plugins/hotkeyPlugin"; import App from "@/components/App.vue"; import { markdownItPlugin } from "@/plugins/markdownItPlugin"; +import { isProduction } from "@/helpers/platform"; import "@quasar/extras/material-symbols-rounded/material-symbols-rounded.css"; import "quasar/dist/quasar.sass"; @@ -18,31 +19,33 @@ import "./styles/_index.scss"; // ため、それを防止するため自前でdataLayerをあらかじめ用意する // window.dataLayer = []; -// Sentry によるエラートラッキングを開始 +// Sentry によるエラートラッキングを開始 (production 環境のみ有効) // ref: https://docs.sentry.io/platforms/javascript/guides/electron/ -Sentry.init( - { - integrations: [ - Sentry.browserTracingIntegration(), - Sentry.replayIntegration(), - ], +if (isProduction) { + Sentry.init( + { + integrations: [ + Sentry.browserTracingIntegration(), + Sentry.replayIntegration(), + ], - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate - tracesSampleRate: 1.0, + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - // Learn more at - // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, - }, - SentryVue.init, -); + // Capture Replay for 10% of all sessions, + // plus for 100% of sessions with an error + // Learn more at + // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, + }, + SentryVue.init, + ); +} createApp(App) .use(store, storeKey)