sobey-monitor-sdk 1.1.13 → 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 +24 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +24 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +24 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ interface BaseData {
|
|
|
163
163
|
/**
|
|
164
164
|
* 错误数据类型
|
|
165
165
|
*/
|
|
166
|
-
type ErrorType = 'js_error' | 'promise_error' | 'resource_error' | 'http_error' | 'white_screen' | 'vue_error' | 'react_error';
|
|
166
|
+
type ErrorType = 'js_error' | 'promise_error' | 'resource_error' | 'http_error' | 'business_error' | 'white_screen' | 'vue_error' | 'react_error';
|
|
167
167
|
/**
|
|
168
168
|
* 错误数据
|
|
169
169
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -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
|
|
@@ -1092,7 +1112,7 @@ function reportHttpError(httpInfo, isBusinessError = false) {
|
|
|
1092
1112
|
? `Business Error ${httpInfo.method} ${httpInfo.url}`
|
|
1093
1113
|
: `HTTP ${httpInfo.status} ${httpInfo.method} ${httpInfo.url}`;
|
|
1094
1114
|
const errorData = {
|
|
1095
|
-
type: 'http_error',
|
|
1115
|
+
type: isBusinessError ? 'business_error' : 'http_error',
|
|
1096
1116
|
message,
|
|
1097
1117
|
httpInfo,
|
|
1098
1118
|
};
|