修复: _sendErrorToWebhook方法优先使用配置中的webhookUrl

This commit is contained in:
yuantao
2026-03-30 18:21:13 +08:00
parent c326a760be
commit 22e48d7db1

View File

@@ -744,16 +744,18 @@ class ErrorMonitor {
* @private
*/
async _sendErrorToWebhook(errorInfo, retryCount = 0, forceSend = false) {
// 环境检查:只在生产环境下发送错误信息
if (!forceSend && !this._isProduction() && !this.config?.forceEnable) {
console.info('非生产环境错误信息不上报到webhook:', errorInfo.type)
return
}
const webhookUrl = import.meta.env.VITE_WEBHOOK
if (!webhookUrl) {
console.error('未配置webhook地址无法发送错误信息')
return
}
// 环境检查:只在生产环境下发送错误信息
if (!forceSend && !this._isProduction() && !this.config?.forceEnable) {
console.info('非生产环境错误信息不上报到webhook:', errorInfo.type)
return
}
// 优先使用配置中的 webhookUrl,否则使用环境变量
const webhookUrl = this.config?.webhookUrl || import.meta.env.VITE_WEBHOOK
if (!webhookUrl) {
console.error('未配置webhook地址无法发送错误信息')
return
}
try {
// 格式化错误信息
const message = this._formatErrorMessage(errorInfo)