sobey-monitor-sdk 1.1.5 → 1.1.7

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 CHANGED
@@ -239,6 +239,8 @@ function supportsSendBeacon() {
239
239
  /**
240
240
  * 数据发送器
241
241
  */
242
+ // 保存原始 fetch,避免使用被 SDK 拦截过的 fetch
243
+ const originalFetch$1 = window.fetch.bind(window);
242
244
  /**
243
245
  * 发送器类
244
246
  */
@@ -335,7 +337,8 @@ class Sender {
335
337
  */
336
338
  sendByFetch(url, payload) {
337
339
  const cfg = config.get();
338
- fetch(url, {
340
+ // 使用原始 fetch,避免触发 SDK 的 HTTP 错误拦截器
341
+ originalFetch$1(url, {
339
342
  method: 'POST',
340
343
  headers: {
341
344
  'Content-Type': 'application/json',
@@ -803,8 +806,8 @@ function interceptXHR() {
803
806
  const duration = Date.now() - monitorData.startTime;
804
807
  const status = this.status;
805
808
  // 根据配置决定是否添加到面包屑
806
- const cfg = config.get();
807
- const recordMode = cfg.behavior?.recordRequestBreadcrumb || 'error';
809
+ const cfg = config.isInitialized() ? config.get() : null;
810
+ const recordMode = cfg?.behavior?.recordRequestBreadcrumb || 'error';
808
811
  // 重定向(3xx)始终记录,不受配置控制
809
812
  const isRedirect = status >= 300 && status < 400;
810
813
  // 其他异常情况(0-网络错误、4xx-客户端错误、5xx-服务端错误)根据配置控制
@@ -854,8 +857,8 @@ function interceptFetch() {
854
857
  const duration = Date.now() - startTime;
855
858
  const status = response.status;
856
859
  // 根据配置决定是否添加到面包屑
857
- const cfg = config.get();
858
- const recordMode = cfg.behavior?.recordRequestBreadcrumb || 'error';
860
+ const cfg = config.isInitialized() ? config.get() : null;
861
+ const recordMode = cfg?.behavior?.recordRequestBreadcrumb || 'error';
859
862
  // 重定向(3xx)始终记录,不受配置控制
860
863
  const isRedirect = status >= 300 && status < 400;
861
864
  // 其他异常情况根据配置控制
@@ -896,8 +899,8 @@ function interceptFetch() {
896
899
  catch (error) {
897
900
  const duration = Date.now() - startTime;
898
901
  // 网络错误时根据配置决定是否添加到面包屑
899
- const cfg = config.get();
900
- const recordMode = cfg.behavior?.recordRequestBreadcrumb || 'error';
902
+ const cfg = config.isInitialized() ? config.get() : null;
903
+ const recordMode = cfg?.behavior?.recordRequestBreadcrumb || 'error';
901
904
  // 网络错误属于 error,当模式为 'all' 或 'error' 时都记录
902
905
  if (recordMode !== 'none') {
903
906
  context.addBreadcrumb({