sobey-monitor-sdk 1.1.10 → 1.1.11

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
@@ -414,10 +414,12 @@ class Reporter {
414
414
  }
415
415
  /**
416
416
  * 发送早期缓存的数据(根据最新配置过滤)
417
+ * 所有数据会先累积到 sender 的缓冲区,最后统一发送一次
417
418
  */
418
419
  flushEarlyBuffer() {
419
420
  const cfg = config.get();
420
421
  let skippedCount = 0;
422
+ let processedCount = 0;
421
423
  // 全局开关检查:如果 enabled 为 false,清空缓存不上报
422
424
  if (cfg.enabled === false) {
423
425
  const totalCount = this.earlyBuffer.length;
@@ -458,6 +460,7 @@ class Reporter {
458
460
  continue;
459
461
  }
460
462
  this.reportError(item.data);
463
+ processedCount++;
461
464
  break;
462
465
  case 'performance':
463
466
  // 检查性能监控是否启用
@@ -466,6 +469,7 @@ class Reporter {
466
469
  continue;
467
470
  }
468
471
  this.reportPerformance(item.data);
472
+ processedCount++;
469
473
  break;
470
474
  case 'behavior':
471
475
  // 检查行为监控是否启用
@@ -484,9 +488,17 @@ class Reporter {
484
488
  continue;
485
489
  }
486
490
  this.reportBehavior(item.data);
491
+ processedCount++;
487
492
  break;
488
493
  }
489
494
  }
495
+ // 所有早期数据已添加到 sender 缓冲区,立即统一发送
496
+ if (processedCount > 0) {
497
+ sender.flush();
498
+ if (cfg.debug) {
499
+ console.log(`[Monitor] Flushed ${processedCount} early buffered items in single batch`);
500
+ }
501
+ }
490
502
  if (skippedCount > 0 && cfg.debug) {
491
503
  console.log(`[Monitor] Filtered out ${skippedCount} early buffered items based on config`);
492
504
  }