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