余尚辉 1 týždeň pred
rodič
commit
388b1dd14a
3 zmenil súbory, kde vykonal 41 pridanie a 2 odobranie
  1. 3 0
      package.json
  2. 22 0
      src/main.js
  3. 16 2
      vite.config.js

+ 3 - 0
package.json

@@ -7,6 +7,7 @@
   "type": "module",
   "scripts": {
     "dev": "vite",
+    "build": "vite build",
     "build:prod": "vite build --mode production",
     "build:jms": "vite build --mode jms",
     "preview": "vite preview"
@@ -17,6 +18,8 @@
   },
   "dependencies": {
     "@element-plus/icons-vue": "2.3.1",
+    "@sentry/vite-plugin": "^3.2.2",
+    "@sentry/vue": "^9.6.0",
     "@vueup/vue-quill": "1.2.0",
     "@vueuse/core": "10.11.0",
     "autofit.js": "^3.2.3",

+ 22 - 0
src/main.js

@@ -46,6 +46,8 @@ import TreeSelect from '@/components/TreeSelect'
 // 字典标签组件
 import DictTag from '@/components/DictTag'
 
+import * as Sentry from "@sentry/vue";
+
 const app = createApp(App)
 
 // 全局方法挂载
@@ -69,6 +71,22 @@ app.component('ImagePreview', ImagePreview)
 app.component('RightToolbar', RightToolbar)
 app.component('Editor', Editor)
 
+Sentry.init({
+  app,
+  dsn: "https://f49d441715062cdbbaa361797e0452e7@sentry.fuxicarbon.com/4",
+  integrations: [
+    Sentry.browserTracingIntegration({ router }),
+    Sentry.replayIntegration(),
+  ],
+  // Tracing
+  tracesSampleRate: 1.0, //  Capture 100% of the transactions
+  // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
+  tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
+  // Session Replay
+  replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
+  replaysOnErrorSampleRate: 1.0, // I
+});
+
 app.use(router)
 app.use(store)
 app.use(plugins)
@@ -83,5 +101,9 @@ app.use(ElementPlus, {
   // 支持 large、default、small
   size: Cookies.get('size') || 'default'
 })
+app.config.errorHandler = (err, instance, info) => {
+  console.error("Vue Error: ", err);
+  Sentry.captureException(err);
+};
 
 app.mount('#app')

+ 16 - 2
vite.config.js

@@ -2,7 +2,7 @@ import { defineConfig, loadEnv } from 'vite'
 import path from 'path'
 import createVitePlugins from './vite/plugins'
 import tailwindcss from 'tailwindcss'
-
+import { sentryVitePlugin } from '@sentry/vite-plugin'
 // https://vitejs.dev/config/
 export default defineConfig(({ mode, command }) => {
   const env = loadEnv(mode, process.cwd())
@@ -13,7 +13,21 @@ export default defineConfig(({ mode, command }) => {
     // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
     // base: VITE_APP_ENV === 'production' ? '/voiceMateWeb/' : '/',
     base: VITE_APP_ENV === 'production' ? '/' : '/',
-    plugins: createVitePlugins(env, command === 'build'),
+    plugins: [
+      createVitePlugins(env, command === 'build'),
+      sentryVitePlugin({
+        url: 'https://sentry.fuxicarbon.com',  // 你的 Sentry 服务器地址
+        org: 'sentry',  // 你的组织名称
+        project: 'test-vue',  // 你的 Sentry 项目名称
+        release: 'sentry001',  // 👈 修正格式,release 需要是 string
+        authToken: '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',  
+        include: './dist',  // 👈 确保匹配你的 `dist` 目录
+        ignore: ['node_modules', 'dist/**/*.html'],  // 忽略 node_modules 和 HTML
+      }),
+    ],
+    build: {
+      sourcemap: true, // 开启 Source Map
+    },
     resolve: {
       // https://cn.vitejs.dev/config/#resolve-alias
       alias: {