sobey-monitor-sdk 1.1.9 → 1.1.10
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 +47 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +47 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +47 -35
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -764,12 +764,20 @@ function installHttpErrorHandler() {
|
|
|
764
764
|
* 检查是否是 SDK 自身的请求
|
|
765
765
|
*/
|
|
766
766
|
function isSdkRequest(url) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
return
|
|
772
|
-
|
|
767
|
+
// 检查是否匹配常见的 SDK 上报路径
|
|
768
|
+
if (url.includes('/monitor/api/report') ||
|
|
769
|
+
url.includes('/monitor/api/beacon') ||
|
|
770
|
+
url.includes('/monitor/api/config')) {
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
// 配置已初始化时,检查 dsn
|
|
774
|
+
if (config.isInitialized()) {
|
|
775
|
+
const cfg = config.get();
|
|
776
|
+
if (cfg.dsn && url.includes(cfg.dsn)) {
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
773
781
|
}
|
|
774
782
|
/**
|
|
775
783
|
* 获取嵌套对象的字段值
|
|
@@ -959,35 +967,39 @@ function interceptFetch() {
|
|
|
959
967
|
},
|
|
960
968
|
});
|
|
961
969
|
}
|
|
962
|
-
//
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
970
|
+
// 检查是否配置了业务错误规则
|
|
971
|
+
const hasBusinessRules = cfg?.error?.businessErrorRules && cfg.error.businessErrorRules.length > 0;
|
|
972
|
+
// 只有在请求失败或配置了业务规则时才读取响应体
|
|
973
|
+
if (!response.ok || hasBusinessRules) {
|
|
974
|
+
const cloned = response.clone();
|
|
975
|
+
let responseBody;
|
|
976
|
+
try {
|
|
977
|
+
responseBody = await cloned.text();
|
|
978
|
+
responseBody = responseBody.substring(0, 1000);
|
|
979
|
+
}
|
|
980
|
+
catch { }
|
|
981
|
+
if (!response.ok) {
|
|
982
|
+
// HTTP 错误
|
|
983
|
+
reportHttpError({
|
|
984
|
+
method,
|
|
985
|
+
url,
|
|
986
|
+
status,
|
|
987
|
+
duration,
|
|
988
|
+
requestBody,
|
|
989
|
+
responseBody,
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
else if (hasBusinessRules && detectBusinessError(responseBody)) {
|
|
993
|
+
// HTTP 200 但检测到业务错误
|
|
994
|
+
reportHttpError({
|
|
995
|
+
method,
|
|
996
|
+
url,
|
|
997
|
+
status,
|
|
998
|
+
duration,
|
|
999
|
+
requestBody,
|
|
1000
|
+
responseBody,
|
|
1001
|
+
}, true);
|
|
1002
|
+
}
|
|
991
1003
|
}
|
|
992
1004
|
return response;
|
|
993
1005
|
}
|