AWS ses

手动配置 https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ 配置DSN 防止额度被盗刷(重要防护) 配置采样率 1 2 3 4 5 6 7 8 9 10 11 12 13 14 { // 1. 错误追踪:前期建议 100% 捕获,因为你是单兵作战,每个报错都很重要 sampleRate: 1.0, // 2. 性能追踪 (Transactions):这是最费钱的 // 建议设置极低,比如 0.1 (10%) 甚至 0.05 (5%) // 你不需要监控每一个用户的页面加载速度,只需要一个统计趋势 tracesSampleRate: 0.1, // 3. Session Replay (回放):非常贵且耗流量 // 正常会话不录屏,只有报错时才录屏 100% replaysSessionSampleRate: 0, replaysOnErrorSampleRate: 1.0, } 过滤垃圾报错 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Sentry.init({ // 简单粗暴的忽略列表 ignoreErrors: [ "ResizeObserver loop limit exceeded", // 经典良性错误,无视 "Non-Error promise rejection captured", "Network Error", // 用户断网,不用报给我 "Failed to fetch", // 同上 "Loading chunk", // 网络波动导致懒加载失败 ], // 或者使用更高级的 beforeSend 过滤 beforeSend(event, hint) { const error = hint.originalException; // 过滤掉爬虫 (User Agent 判断) if (event.request?.headers?.['User-Agent']?.includes('Googlebot')) { return null; } return event; }, }); 上传 Source Maps 获取 Sentry Auth Token (专用上传令牌): User Settings -> Developer Settings -> Personal Settings 配置 Cloudflare 环境变量 配置 next.config.mjs (SDK v8 语法) 验证上传是否成功 关联用户身份 (User Context) 脚本配置 第一步:准备 Sentry 项目 注册/登录 sentry.io。 点击 Create Project。 选择平台:Next.js。 Alert Frequency:建议选 “I’ll create my own alerts later”(避免初始邮件轰炸)。 输入项目名称(例如 my-saas-frontend),点击 Create Project。 第二步:使用官方向导自动安装 (推荐) 复制官方向导命令,打开你的 Next.js 项目终端,运行命令: ...

八月 19, 2025 · 4 分钟 · 1750 字 · Kevin