From 035c609634669d411f851f0bfddbfd271a3c7eb1 Mon Sep 17 00:00:00 2001 From: fhzit <152045732+fhzit@users.noreply.github.com> Date: Sat, 5 Apr 2025 12:51:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=84=91?= =?UTF-8?q?=E6=8A=BD=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了脑抽导致的问题 --- src/.vuepress/enhanceApp.js | 94 ------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 src/.vuepress/enhanceApp.js diff --git a/src/.vuepress/enhanceApp.js b/src/.vuepress/enhanceApp.js deleted file mode 100644 index 054bad2..0000000 --- a/src/.vuepress/enhanceApp.js +++ /dev/null @@ -1,94 +0,0 @@ -// .vuepress/enhanceApp.js -import * as Sentry from '@sentry/browser'; -import { Vue as VueIntegration } from '@sentry/integrations'; -import { Integrations } from '@sentry/tracing'; - -export default ({ Vue, router }) => { - // 仅在生产环境启用 Sentry - if (process.env.NODE_ENV === 'production') { - // 初始化 Sentry - Sentry.init({ - dsn: 'https://f8ab1b11ab45f86bd6c4237ba16cb5fe@o4508946125619200.ingest.de.sentry.io/4509058673606736', - integrations: [ - // 自动捕获 Vue 组件错误 - new VueIntegration({ - Vue, - attachProps: true, // 记录组件 props - logErrors: false // 关闭控制台错误重复输出 - }), - // 启用性能监控 - new Integrations.BrowserTracing({ - routingInstrumentation: Sentry.vueRouterInstrumentation(router), - tracingOrigins: ['localhost', /^\//] - }) - ], - environment: 'production', - release: 'vuepress-docs@1.0.0', // 需与构建版本一致 - tracesSampleRate: 0.3, // 30%的性能数据采样 - autoSessionTracking: true, // 自动会话跟踪 - beforeSend(event) { - // 过滤敏感信息(示例) - if (event.request?.url) { - event.request.url = event.request.url.replace(/password=[^&]*/, 'password=[REDACTED]'); - } - return event; - } - }); - - // ================= 手动用户行为记录 ================= - - // 1. 路由导航追踪 - router.beforeEach((to, from, next) => { - // 记录面包屑导航 - Sentry.addBreadcrumb({ - category: 'navigation', - message: `Route change: ${from.path} → ${to.path}`, - level: 'info' - }); - next(); - }); - - // 2. 页面访问事件记录 - router.afterEach((to) => { - Sentry.captureEvent({ - message: 'Page View', - level: 'info', - tags: { - route: to.path, - referrer: document.referrer || 'direct' - }, - extra: { - fullPath: to.fullPath, - userAgent: navigator.userAgent - } - }); - }); - - // 3. 全局错误处理器(补充) - window.addEventListener('unhandledrejection', (event) => { - Sentry.captureException(event.reason, { - contexts: { - promise: { - rejection: event.reason?.stack || String(event.reason) - } - } - }); - }); - } else { - console.log('[Sentry] 开发模式已禁用监控'); - } - - // ================= 扩展方法示例 ================= - // 可在 Vue 原型上添加方法供组件调用 - Vue.prototype.$trackEvent = (eventName, payload) => { - if (process.env.NODE_ENV === 'production') { - Sentry.captureEvent({ - message: eventName, - level: 'info', - contexts: { - custom: payload - } - }); - } - }; - }; \ No newline at end of file