sobey-monitor-sdk 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +30 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +30 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +30 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -770,8 +770,8 @@
|
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
772
772
|
const tagName = target.tagName.toLowerCase();
|
|
773
|
-
//
|
|
774
|
-
if (!['img', 'script', 'link', 'video', 'audio', 'source'].includes(tagName)) {
|
|
773
|
+
// 只监控特定标签的资源(包括 iframe)
|
|
774
|
+
if (!['img', 'script', 'link', 'video', 'audio', 'source', 'iframe'].includes(tagName)) {
|
|
775
775
|
return;
|
|
776
776
|
}
|
|
777
777
|
// 获取资源 URL
|
|
@@ -836,6 +836,30 @@
|
|
|
836
836
|
}
|
|
837
837
|
return false;
|
|
838
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
* 根据配置的状态码列表判断是否应该上报 HTTP 错误
|
|
841
|
+
* @param status HTTP 状态码
|
|
842
|
+
* @returns 是否应该上报
|
|
843
|
+
*/
|
|
844
|
+
function shouldReportHttpError(status) {
|
|
845
|
+
// 获取配置的状态码列表
|
|
846
|
+
if (!config.isInitialized()) {
|
|
847
|
+
// 配置未初始化时,不上报
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
const cfg = config.get();
|
|
851
|
+
const httpErrorStatusCodes = cfg.error?.httpErrorStatusCodes;
|
|
852
|
+
// 如果未配置状态码列表或为空数组,则不上报任何HTTP错误
|
|
853
|
+
if (!httpErrorStatusCodes || httpErrorStatusCodes.length === 0) {
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
// 只检查状态码是否在配置的列表中
|
|
857
|
+
const shouldReport = httpErrorStatusCodes.includes(status);
|
|
858
|
+
if (cfg.debug) {
|
|
859
|
+
console.log(`[Monitor] HTTP status ${status} shouldReport: ${shouldReport}, configured codes:`, httpErrorStatusCodes);
|
|
860
|
+
}
|
|
861
|
+
return shouldReport;
|
|
862
|
+
}
|
|
839
863
|
/**
|
|
840
864
|
* 获取嵌套对象的字段值
|
|
841
865
|
* @param obj 对象
|
|
@@ -981,8 +1005,8 @@
|
|
|
981
1005
|
});
|
|
982
1006
|
}
|
|
983
1007
|
const responseBody = this.responseText?.substring(0, 1000);
|
|
984
|
-
// HTTP
|
|
985
|
-
if (status
|
|
1008
|
+
// HTTP 错误(根据配置的状态码列表过滤)
|
|
1009
|
+
if (shouldReportHttpError(status)) {
|
|
986
1010
|
reportHttpError({
|
|
987
1011
|
method: monitorData.method,
|
|
988
1012
|
url: monitorData.url,
|
|
@@ -1055,8 +1079,8 @@
|
|
|
1055
1079
|
responseBody = responseBody.substring(0, 1000);
|
|
1056
1080
|
}
|
|
1057
1081
|
catch { }
|
|
1058
|
-
if (!response.ok) {
|
|
1059
|
-
// HTTP
|
|
1082
|
+
if (!response.ok && shouldReportHttpError(status)) {
|
|
1083
|
+
// HTTP 错误(根据配置的状态码列表过滤)
|
|
1060
1084
|
reportHttpError({
|
|
1061
1085
|
method,
|
|
1062
1086
|
url,
|