sobey-monitor-sdk 1.1.17 → 1.1.18

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
@@ -429,11 +429,11 @@
429
429
  });
430
430
  }
431
431
 
432
+ var version = "1.1.17";
433
+
432
434
  /**
433
435
  * 数据上报管理
434
436
  */
435
- // SDK 版本
436
- const SDK_VERSION$1 = '1.0.0';
437
437
  /**
438
438
  * 上报器类
439
439
  */
@@ -570,7 +570,7 @@
570
570
  pageUrl: getPageUrl(),
571
571
  timestamp: Date.now(),
572
572
  userAgent: getUserAgent(),
573
- sdkVersion: cfg.version || SDK_VERSION$1,
573
+ sdkVersion: cfg.version || version,
574
574
  };
575
575
  }
576
576
  /**
@@ -845,19 +845,20 @@
845
845
  // 获取配置的状态码列表
846
846
  if (!config.isInitialized()) {
847
847
  // 配置未初始化时,不上报
848
+ console.log(`[Monitor] shouldReportHttpError: config not initialized, status=${status}, returning false`);
848
849
  return false;
849
850
  }
850
851
  const cfg = config.get();
851
852
  const httpErrorStatusCodes = cfg.error?.httpErrorStatusCodes;
852
853
  // 如果未配置状态码列表或为空数组,则不上报任何HTTP错误
853
854
  if (!httpErrorStatusCodes || httpErrorStatusCodes.length === 0) {
855
+ console.log(`[Monitor] shouldReportHttpError: no httpErrorStatusCodes configured, status=${status}, returning false`);
854
856
  return false;
855
857
  }
856
858
  // 只检查状态码是否在配置的列表中
857
859
  const shouldReport = httpErrorStatusCodes.includes(status);
858
- if (cfg.debug) {
859
- console.log(`[Monitor] HTTP status ${status} shouldReport: ${shouldReport}, configured codes:`, httpErrorStatusCodes);
860
- }
860
+ // 临时强制输出调试日志
861
+ console.log(`[Monitor] HTTP status ${status} shouldReport: ${shouldReport}, configured codes:`, httpErrorStatusCodes);
861
862
  return shouldReport;
862
863
  }
863
864
  /**
@@ -1123,13 +1124,16 @@
1123
1124
  },
1124
1125
  });
1125
1126
  }
1126
- reportHttpError({
1127
- method,
1128
- url,
1129
- status: 0,
1130
- duration,
1131
- requestBody,
1132
- });
1127
+ // 网络错误也遵守 httpErrorStatusCodes 配置
1128
+ if (shouldReportHttpError(0)) {
1129
+ reportHttpError({
1130
+ method,
1131
+ url,
1132
+ status: 0,
1133
+ duration,
1134
+ requestBody,
1135
+ });
1136
+ }
1133
1137
  throw error;
1134
1138
  }
1135
1139
  };
@@ -1940,8 +1944,6 @@
1940
1944
  * 前端监控 SDK
1941
1945
  * @description 错误监控、性能监控、行为监控
1942
1946
  */
1943
- // SDK 版本
1944
- const SDK_VERSION = '1.0.0';
1945
1947
  /**
1946
1948
  * 监控 SDK 主类
1947
1949
  */
@@ -2019,7 +2021,7 @@
2019
2021
  // 初始化配置管理器
2020
2022
  config.init({
2021
2023
  ...finalConfig,
2022
- version: finalConfig.version || SDK_VERSION,
2024
+ version: finalConfig.version || version,
2023
2025
  }, true);
2024
2026
  this.ready = true;
2025
2027
  this.loading = false;
@@ -2196,7 +2198,7 @@
2196
2198
  * 获取 SDK 版本
2197
2199
  */
2198
2200
  getVersion() {
2199
- return SDK_VERSION;
2201
+ return version;
2200
2202
  }
2201
2203
  }
2202
2204
  // 导出单例