@logspace/sdk 1.1.6 → 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 +29 -3
- package/logspace.esm.js.map +1 -1
- package/logspace.iife.js +1 -1
- package/logspace.iife.js.map +1 -1
- package/logspace.umd.js +1 -1
- package/logspace.umd.js.map +1 -1
- package/package.json +1 -1
package/logspace.esm.js
CHANGED
|
@@ -14524,6 +14524,10 @@ 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 rateLimitWarnedThisWindow = false;
|
|
14528
|
+
let rateLimitDroppedCount = 0;
|
|
14529
|
+
let rrwebRateLimiter = { count: 0, windowStart: 0 };
|
|
14530
|
+
const RRWEB_RATE_LIMIT = 500;
|
|
14527
14531
|
let idleTimer = null;
|
|
14528
14532
|
let durationTimer = null;
|
|
14529
14533
|
let checkpointTimer = null;
|
|
@@ -14744,14 +14748,23 @@ function checkRateLimit() {
|
|
|
14744
14748
|
const now = Date.now();
|
|
14745
14749
|
const windowMs = 1e3;
|
|
14746
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
|
+
}
|
|
14747
14754
|
rateLimiter.windowStart = now;
|
|
14748
14755
|
rateLimiter.count = 1;
|
|
14756
|
+
rateLimitWarnedThisWindow = false;
|
|
14757
|
+
rateLimitDroppedCount = 0;
|
|
14749
14758
|
return true;
|
|
14750
14759
|
}
|
|
14751
14760
|
rateLimiter.count++;
|
|
14752
14761
|
if (rateLimiter.count > config.limits.rateLimit) {
|
|
14753
|
-
|
|
14754
|
-
|
|
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
|
+
);
|
|
14755
14768
|
}
|
|
14756
14769
|
return false;
|
|
14757
14770
|
}
|
|
@@ -15952,6 +15965,9 @@ const LogSpace = {
|
|
|
15952
15965
|
currentSize = 0;
|
|
15953
15966
|
rrwebSize = 0;
|
|
15954
15967
|
rateLimiter = { count: 0, windowStart: 0 };
|
|
15968
|
+
rrwebRateLimiter = { count: 0, windowStart: 0 };
|
|
15969
|
+
rateLimitWarnedThisWindow = false;
|
|
15970
|
+
rateLimitDroppedCount = 0;
|
|
15955
15971
|
deduplication = { lastLogHash: null, lastLogCount: 0 };
|
|
15956
15972
|
endReason = "manual";
|
|
15957
15973
|
let sessionId;
|
|
@@ -16019,7 +16035,17 @@ const LogSpace = {
|
|
|
16019
16035
|
},
|
|
16020
16036
|
(event) => {
|
|
16021
16037
|
if (!session || session.status !== "recording") return;
|
|
16022
|
-
const
|
|
16038
|
+
const now = Date.now();
|
|
16039
|
+
if (now - rrwebRateLimiter.windowStart > 1e3) {
|
|
16040
|
+
rrwebRateLimiter.windowStart = now;
|
|
16041
|
+
rrwebRateLimiter.count = 1;
|
|
16042
|
+
} else {
|
|
16043
|
+
rrwebRateLimiter.count++;
|
|
16044
|
+
if (rrwebRateLimiter.count > RRWEB_RATE_LIMIT) {
|
|
16045
|
+
return;
|
|
16046
|
+
}
|
|
16047
|
+
}
|
|
16048
|
+
const eventSize = event.type === 2 ? 5e4 : 500;
|
|
16023
16049
|
rrwebSize += eventSize;
|
|
16024
16050
|
const totalSize = currentSize + rrwebSize;
|
|
16025
16051
|
if (config && totalSize >= config.limits.maxSize) {
|