sobey-monitor-sdk 1.1.14 → 1.1.15
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 +23 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +23 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -858,13 +858,26 @@
|
|
|
858
858
|
*/
|
|
859
859
|
function matchRule(data, rule) {
|
|
860
860
|
const value = getNestedValue(data, rule.field);
|
|
861
|
+
// 辅助函数:比较两个值(支持数字和字符串的混合比较)
|
|
862
|
+
const isEqual = (a, b) => {
|
|
863
|
+
if (a === b)
|
|
864
|
+
return true;
|
|
865
|
+
// 处理数字和字符串的混合比较:500 == "500"
|
|
866
|
+
if (typeof a === 'number' && typeof b === 'string') {
|
|
867
|
+
return a === Number(b);
|
|
868
|
+
}
|
|
869
|
+
if (typeof a === 'string' && typeof b === 'number') {
|
|
870
|
+
return Number(a) === b;
|
|
871
|
+
}
|
|
872
|
+
return false;
|
|
873
|
+
};
|
|
861
874
|
switch (rule.operator) {
|
|
862
875
|
case 'exists':
|
|
863
876
|
return value !== undefined && value !== null;
|
|
864
877
|
case 'eq':
|
|
865
|
-
return value
|
|
878
|
+
return isEqual(value, rule.value);
|
|
866
879
|
case 'ne':
|
|
867
|
-
return value
|
|
880
|
+
return !isEqual(value, rule.value);
|
|
868
881
|
case 'gt':
|
|
869
882
|
return typeof value === 'number' && typeof rule.value === 'number' && value > rule.value;
|
|
870
883
|
case 'gte':
|
|
@@ -889,8 +902,15 @@
|
|
|
889
902
|
return false;
|
|
890
903
|
const cfg = config.get();
|
|
891
904
|
const rules = cfg.error?.businessErrorRules;
|
|
892
|
-
if (!rules || rules.length === 0)
|
|
905
|
+
if (!rules || rules.length === 0) {
|
|
906
|
+
if (cfg.debug) {
|
|
907
|
+
console.log('[Monitor] No businessErrorRules configured');
|
|
908
|
+
}
|
|
893
909
|
return false;
|
|
910
|
+
}
|
|
911
|
+
if (cfg.debug) {
|
|
912
|
+
console.log('[Monitor] Checking businessErrorRules:', rules, 'responseBody:', responseBody.substring(0, 200));
|
|
913
|
+
}
|
|
894
914
|
try {
|
|
895
915
|
const data = JSON.parse(responseBody);
|
|
896
916
|
// 任一规则匹配时返回 true
|