You've already forked uniapp-error-monitor
修复: _sendErrorToWebhook方法优先使用配置中的webhookUrl
This commit is contained in:
22
src/index.js
22
src/index.js
@@ -744,16 +744,18 @@ class ErrorMonitor {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _sendErrorToWebhook(errorInfo, retryCount = 0, forceSend = false) {
|
async _sendErrorToWebhook(errorInfo, retryCount = 0, forceSend = false) {
|
||||||
// 环境检查:只在生产环境下发送错误信息
|
// 环境检查:只在生产环境下发送错误信息
|
||||||
if (!forceSend && !this._isProduction() && !this.config?.forceEnable) {
|
if (!forceSend && !this._isProduction() && !this.config?.forceEnable) {
|
||||||
console.info('非生产环境,错误信息不上报到webhook:', errorInfo.type)
|
console.info('非生产环境,错误信息不上报到webhook:', errorInfo.type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const webhookUrl = import.meta.env.VITE_WEBHOOK
|
|
||||||
if (!webhookUrl) {
|
// 优先使用配置中的 webhookUrl,否则使用环境变量
|
||||||
console.error('未配置webhook地址,无法发送错误信息')
|
const webhookUrl = this.config?.webhookUrl || import.meta.env.VITE_WEBHOOK
|
||||||
return
|
if (!webhookUrl) {
|
||||||
}
|
console.error('未配置webhook地址,无法发送错误信息')
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// 格式化错误信息
|
// 格式化错误信息
|
||||||
const message = this._formatErrorMessage(errorInfo)
|
const message = this._formatErrorMessage(errorInfo)
|
||||||
|
|||||||
Reference in New Issue
Block a user