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