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