@logspace/sdk 1.1.7 → 1.1.8

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/logspace.esm.js CHANGED
@@ -14524,8 +14524,8 @@ let rateLimiter = { count: 0, windowStart: 0 };
14524
14524
  let deduplication = { lastLogHash: null, lastLogCount: 0 };
14525
14525
  let currentSize = 0;
14526
14526
  let rrwebSize = 0;
14527
- let lastRateLimitWarningTime = 0;
14528
- const RATE_LIMIT_WARNING_THROTTLE_MS = 1e3;
14527
+ let rateLimitWarnedThisWindow = false;
14528
+ let rateLimitDroppedCount = 0;
14529
14529
  let rrwebRateLimiter = { count: 0, windowStart: 0 };
14530
14530
  const RRWEB_RATE_LIMIT = 500;
14531
14531
  let idleTimer = null;
@@ -14748,18 +14748,23 @@ function checkRateLimit() {
14748
14748
  const now = Date.now();
14749
14749
  const windowMs = 1e3;
14750
14750
  if (now - rateLimiter.windowStart > windowMs) {
14751
+ if (config.debug && rateLimitDroppedCount > 0) {
14752
+ console.warn(`[LogSpace] Rate limit: dropped ${rateLimitDroppedCount} logs in last second`);
14753
+ }
14751
14754
  rateLimiter.windowStart = now;
14752
14755
  rateLimiter.count = 1;
14756
+ rateLimitWarnedThisWindow = false;
14757
+ rateLimitDroppedCount = 0;
14753
14758
  return true;
14754
14759
  }
14755
14760
  rateLimiter.count++;
14756
14761
  if (rateLimiter.count > config.limits.rateLimit) {
14757
- if (config.debug) {
14758
- const now2 = Date.now();
14759
- if (now2 - lastRateLimitWarningTime >= RATE_LIMIT_WARNING_THROTTLE_MS) {
14760
- lastRateLimitWarningTime = now2;
14761
- console.warn("[LogSpace] Rate limit exceeded, dropping log");
14762
- }
14762
+ rateLimitDroppedCount++;
14763
+ if (!rateLimitWarnedThisWindow) {
14764
+ rateLimitWarnedThisWindow = true;
14765
+ console.warn(
14766
+ `[LogSpace] Rate limit exceeded (${config.limits.rateLimit}/sec). Logs are being dropped. Consider increasing limits.rateLimit or disabling noisy captures.`
14767
+ );
14763
14768
  }
14764
14769
  return false;
14765
14770
  }
@@ -15961,7 +15966,8 @@ const LogSpace = {
15961
15966
  rrwebSize = 0;
15962
15967
  rateLimiter = { count: 0, windowStart: 0 };
15963
15968
  rrwebRateLimiter = { count: 0, windowStart: 0 };
15964
- lastRateLimitWarningTime = 0;
15969
+ rateLimitWarnedThisWindow = false;
15970
+ rateLimitDroppedCount = 0;
15965
15971
  deduplication = { lastLogHash: null, lastLogCount: 0 };
15966
15972
  endReason = "manual";
15967
15973
  let sessionId;