Skip to content

Commit

Permalink
Fix: 開発環境では Sentry を無効化する
Browse files Browse the repository at this point in the history
開発環境ではエラーが起こること前提でテストしたりもするため、それらが一々 Issue に送られていたら対処にキリがなくなる
あくまで本番環境で稼働しているソフトウェアのエラーを把握することが目的なので、開発環境ではエラーを送らないようにした
  • Loading branch information
tsukumijima committed Jan 14, 2025
1 parent 378353a commit 8fe46fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
15 changes: 9 additions & 6 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 以上のログをコンソールに出力
Expand Down
47 changes: 25 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
Expand Down

0 comments on commit 8fe46fd

Please sign in to comment.