sobey-monitor-sdk 1.1.14 → 1.1.16
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 +25 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +25 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +25 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -768,8 +768,8 @@ function installResourceErrorHandler() {
|
|
|
768
768
|
return;
|
|
769
769
|
}
|
|
770
770
|
const tagName = target.tagName.toLowerCase();
|
|
771
|
-
//
|
|
772
|
-
if (!['img', 'script', 'link', 'video', 'audio', 'source'].includes(tagName)) {
|
|
771
|
+
// 只监控特定标签的资源(包括 iframe)
|
|
772
|
+
if (!['img', 'script', 'link', 'video', 'audio', 'source', 'iframe'].includes(tagName)) {
|
|
773
773
|
return;
|
|
774
774
|
}
|
|
775
775
|
// 获取资源 URL
|
|
@@ -856,13 +856,26 @@ function getNestedValue(obj, path) {
|
|
|
856
856
|
*/
|
|
857
857
|
function matchRule(data, rule) {
|
|
858
858
|
const value = getNestedValue(data, rule.field);
|
|
859
|
+
// 辅助函数:比较两个值(支持数字和字符串的混合比较)
|
|
860
|
+
const isEqual = (a, b) => {
|
|
861
|
+
if (a === b)
|
|
862
|
+
return true;
|
|
863
|
+
// 处理数字和字符串的混合比较:500 == "500"
|
|
864
|
+
if (typeof a === 'number' && typeof b === 'string') {
|
|
865
|
+
return a === Number(b);
|
|
866
|
+
}
|
|
867
|
+
if (typeof a === 'string' && typeof b === 'number') {
|
|
868
|
+
return Number(a) === b;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
};
|
|
859
872
|
switch (rule.operator) {
|
|
860
873
|
case 'exists':
|
|
861
874
|
return value !== undefined && value !== null;
|
|
862
875
|
case 'eq':
|
|
863
|
-
return value
|
|
876
|
+
return isEqual(value, rule.value);
|
|
864
877
|
case 'ne':
|
|
865
|
-
return value
|
|
878
|
+
return !isEqual(value, rule.value);
|
|
866
879
|
case 'gt':
|
|
867
880
|
return typeof value === 'number' && typeof rule.value === 'number' && value > rule.value;
|
|
868
881
|
case 'gte':
|
|
@@ -887,8 +900,15 @@ function detectBusinessError(responseBody) {
|
|
|
887
900
|
return false;
|
|
888
901
|
const cfg = config.get();
|
|
889
902
|
const rules = cfg.error?.businessErrorRules;
|
|
890
|
-
if (!rules || rules.length === 0)
|
|
903
|
+
if (!rules || rules.length === 0) {
|
|
904
|
+
if (cfg.debug) {
|
|
905
|
+
console.log('[Monitor] No businessErrorRules configured');
|
|
906
|
+
}
|
|
891
907
|
return false;
|
|
908
|
+
}
|
|
909
|
+
if (cfg.debug) {
|
|
910
|
+
console.log('[Monitor] Checking businessErrorRules:', rules, 'responseBody:', responseBody.substring(0, 200));
|
|
911
|
+
}
|
|
892
912
|
try {
|
|
893
913
|
const data = JSON.parse(responseBody);
|
|
894
914
|
// 任一规则匹配时返回 true
|