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