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.esm.js
CHANGED
|
@@ -764,8 +764,8 @@ function installResourceErrorHandler() {
|
|
|
764
764
|
return;
|
|
765
765
|
}
|
|
766
766
|
const tagName = target.tagName.toLowerCase();
|
|
767
|
-
//
|
|
768
|
-
if (!['img', 'script', 'link', 'video', 'audio', 'source'].includes(tagName)) {
|
|
767
|
+
// 只监控特定标签的资源(包括 iframe)
|
|
768
|
+
if (!['img', 'script', 'link', 'video', 'audio', 'source', 'iframe'].includes(tagName)) {
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
771
|
// 获取资源 URL
|
|
@@ -852,13 +852,26 @@ function getNestedValue(obj, path) {
|
|
|
852
852
|
*/
|
|
853
853
|
function matchRule(data, rule) {
|
|
854
854
|
const value = getNestedValue(data, rule.field);
|
|
855
|
+
// 辅助函数:比较两个值(支持数字和字符串的混合比较)
|
|
856
|
+
const isEqual = (a, b) => {
|
|
857
|
+
if (a === b)
|
|
858
|
+
return true;
|
|
859
|
+
// 处理数字和字符串的混合比较:500 == "500"
|
|
860
|
+
if (typeof a === 'number' && typeof b === 'string') {
|
|
861
|
+
return a === Number(b);
|
|
862
|
+
}
|
|
863
|
+
if (typeof a === 'string' && typeof b === 'number') {
|
|
864
|
+
return Number(a) === b;
|
|
865
|
+
}
|
|
866
|
+
return false;
|
|
867
|
+
};
|
|
855
868
|
switch (rule.operator) {
|
|
856
869
|
case 'exists':
|
|
857
870
|
return value !== undefined && value !== null;
|
|
858
871
|
case 'eq':
|
|
859
|
-
return value
|
|
872
|
+
return isEqual(value, rule.value);
|
|
860
873
|
case 'ne':
|
|
861
|
-
return value
|
|
874
|
+
return !isEqual(value, rule.value);
|
|
862
875
|
case 'gt':
|
|
863
876
|
return typeof value === 'number' && typeof rule.value === 'number' && value > rule.value;
|
|
864
877
|
case 'gte':
|
|
@@ -883,8 +896,15 @@ function detectBusinessError(responseBody) {
|
|
|
883
896
|
return false;
|
|
884
897
|
const cfg = config.get();
|
|
885
898
|
const rules = cfg.error?.businessErrorRules;
|
|
886
|
-
if (!rules || rules.length === 0)
|
|
899
|
+
if (!rules || rules.length === 0) {
|
|
900
|
+
if (cfg.debug) {
|
|
901
|
+
console.log('[Monitor] No businessErrorRules configured');
|
|
902
|
+
}
|
|
887
903
|
return false;
|
|
904
|
+
}
|
|
905
|
+
if (cfg.debug) {
|
|
906
|
+
console.log('[Monitor] Checking businessErrorRules:', rules, 'responseBody:', responseBody.substring(0, 200));
|
|
907
|
+
}
|
|
888
908
|
try {
|
|
889
909
|
const data = JSON.parse(responseBody);
|
|
890
910
|
// 任一规则匹配时返回 true
|