@djangocfg/monitor 2.1.238 → 2.1.240
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/client.cjs +24 -22
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.mjs +24 -22
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/package.json +2 -2
- package/src/client/capture/console.ts +4 -4
- package/src/client/capture/js-errors.ts +4 -5
- package/src/client/capture/network.ts +5 -4
- package/src/client/capture/validation.ts +5 -4
- package/src/client/constants.ts +6 -0
- package/src/client/store/index.ts +9 -11
- package/src/types/config.ts +4 -0
package/dist/client.cjs
CHANGED
|
@@ -1364,12 +1364,16 @@ __name(sendBatch, "sendBatch");
|
|
|
1364
1364
|
// src/client/utils/env.ts
|
|
1365
1365
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
1366
1366
|
var isProduction = !isDevelopment;
|
|
1367
|
-
var MONITOR_VERSION = "2.1.
|
|
1367
|
+
var MONITOR_VERSION = "2.1.240";
|
|
1368
|
+
|
|
1369
|
+
// src/client/constants.ts
|
|
1370
|
+
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|
|
1371
|
+
var DEFAULT_DEDUPE_TTL = 5e3;
|
|
1372
|
+
var DEFAULT_DEDUPE_STORE_TTL = 3e4;
|
|
1368
1373
|
|
|
1369
1374
|
// src/client/store/index.ts
|
|
1370
1375
|
var CIRCUIT_BREAKER_THRESHOLD = 3;
|
|
1371
1376
|
var CIRCUIT_BREAKER_COOLDOWN_MS = 6e4;
|
|
1372
|
-
var STORE_DEDUP_TTL = 5e3;
|
|
1373
1377
|
var STORE_DEDUP_MAX = 200;
|
|
1374
1378
|
var _recentPushKeys = /* @__PURE__ */ new Map();
|
|
1375
1379
|
function _pushDedupeKey(event) {
|
|
@@ -1377,14 +1381,14 @@ function _pushDedupeKey(event) {
|
|
|
1377
1381
|
return `${event.event_type}:${event.level}:${msg}:${event.http_url ?? event.url ?? ""}`;
|
|
1378
1382
|
}
|
|
1379
1383
|
__name(_pushDedupeKey, "_pushDedupeKey");
|
|
1380
|
-
function _isRecentPush(key) {
|
|
1384
|
+
function _isRecentPush(key, ttl) {
|
|
1381
1385
|
const now = Date.now();
|
|
1382
1386
|
const last = _recentPushKeys.get(key);
|
|
1383
|
-
if (last !== void 0 && now - last <
|
|
1387
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1384
1388
|
_recentPushKeys.set(key, now);
|
|
1385
1389
|
if (_recentPushKeys.size > STORE_DEDUP_MAX) {
|
|
1386
1390
|
for (const [k, ts] of _recentPushKeys) {
|
|
1387
|
-
if (now - ts >
|
|
1391
|
+
if (now - ts > ttl) _recentPushKeys.delete(k);
|
|
1388
1392
|
}
|
|
1389
1393
|
}
|
|
1390
1394
|
return false;
|
|
@@ -1397,9 +1401,10 @@ var monitorStore = (0, import_vanilla.createStore)((set, get) => ({
|
|
|
1397
1401
|
_consecutiveFailures: 0,
|
|
1398
1402
|
_pausedUntil: 0,
|
|
1399
1403
|
push(event) {
|
|
1400
|
-
const dedupeKey = _pushDedupeKey(event);
|
|
1401
|
-
if (_isRecentPush(dedupeKey)) return;
|
|
1402
1404
|
const { config, buffer } = get();
|
|
1405
|
+
const storeTtl = config.dedupeStoreTtl ?? DEFAULT_DEDUPE_STORE_TTL;
|
|
1406
|
+
const dedupeKey = _pushDedupeKey(event);
|
|
1407
|
+
if (_isRecentPush(dedupeKey, storeTtl)) return;
|
|
1403
1408
|
const maxSize = config.maxBufferSize ?? 20;
|
|
1404
1409
|
const sanitized = {
|
|
1405
1410
|
build_id: event.build_id ?? config.buildId ?? `sdk:${MONITOR_VERSION}`,
|
|
@@ -1427,8 +1432,8 @@ var monitorStore = (0, import_vanilla.createStore)((set, get) => ({
|
|
|
1427
1432
|
const { buffer, _pausedUntil } = get();
|
|
1428
1433
|
if (buffer.length === 0) return;
|
|
1429
1434
|
if (Date.now() < _pausedUntil) return;
|
|
1430
|
-
const batch = buffer.slice(0,
|
|
1431
|
-
set({ buffer: buffer.slice(
|
|
1435
|
+
const batch = buffer.slice(0, 25);
|
|
1436
|
+
set({ buffer: buffer.slice(25) });
|
|
1432
1437
|
sendBatch({ events: batch }, useBeacon).then(
|
|
1433
1438
|
() => {
|
|
1434
1439
|
set({ _consecutiveFailures: 0, _pausedUntil: 0 });
|
|
@@ -1445,9 +1450,6 @@ var monitorStore = (0, import_vanilla.createStore)((set, get) => ({
|
|
|
1445
1450
|
}
|
|
1446
1451
|
}));
|
|
1447
1452
|
|
|
1448
|
-
// src/client/constants.ts
|
|
1449
|
-
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|
|
1450
|
-
|
|
1451
1453
|
// src/client/capture/js-errors.ts
|
|
1452
1454
|
var MSG_MAX = 2e3;
|
|
1453
1455
|
function truncate(s, max = MSG_MAX) {
|
|
@@ -1470,12 +1472,12 @@ function isHydrationNoise(msg) {
|
|
|
1470
1472
|
return HYDRATION_NOISE.some((p) => p.test(msg));
|
|
1471
1473
|
}
|
|
1472
1474
|
__name(isHydrationNoise, "isHydrationNoise");
|
|
1473
|
-
var CLIENT_DEDUP_TTL = 5 * 60 * 1e3;
|
|
1474
1475
|
var recentFingerprints = /* @__PURE__ */ new Map();
|
|
1475
1476
|
function isRecentlySent(fingerprint) {
|
|
1477
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1476
1478
|
const now = Date.now();
|
|
1477
1479
|
const last = recentFingerprints.get(fingerprint);
|
|
1478
|
-
if (last !== void 0 && now - last <
|
|
1480
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1479
1481
|
recentFingerprints.set(fingerprint, now);
|
|
1480
1482
|
if (recentFingerprints.size > 100) {
|
|
1481
1483
|
const oldest = [...recentFingerprints.entries()].sort((a, b) => a[1] - b[1])[0];
|
|
@@ -1560,12 +1562,12 @@ var typeMap = {
|
|
|
1560
1562
|
error: "ERROR" /* ERROR */
|
|
1561
1563
|
};
|
|
1562
1564
|
var ARG_MAX = 500;
|
|
1563
|
-
var CONSOLE_DEDUP_TTL = 5 * 60 * 1e3;
|
|
1564
1565
|
var recentConsoleFingerprints = /* @__PURE__ */ new Map();
|
|
1565
1566
|
function isRecentConsole(fingerprint) {
|
|
1567
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1566
1568
|
const now = Date.now();
|
|
1567
1569
|
const last = recentConsoleFingerprints.get(fingerprint);
|
|
1568
|
-
if (last !== void 0 && now - last <
|
|
1570
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1569
1571
|
recentConsoleFingerprints.set(fingerprint, now);
|
|
1570
1572
|
if (recentConsoleFingerprints.size > 100) {
|
|
1571
1573
|
const oldest = [...recentConsoleFingerprints.entries()].sort((a, b) => a[1] - b[1])[0];
|
|
@@ -1651,16 +1653,16 @@ function installConsoleCapture() {
|
|
|
1651
1653
|
__name(installConsoleCapture, "installConsoleCapture");
|
|
1652
1654
|
|
|
1653
1655
|
// src/client/capture/validation.ts
|
|
1654
|
-
var VALIDATION_DEDUP_TTL = 1e4;
|
|
1655
1656
|
var recentValidations = /* @__PURE__ */ new Map();
|
|
1656
1657
|
function isRecentValidation(key) {
|
|
1658
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1657
1659
|
const now = Date.now();
|
|
1658
1660
|
const last = recentValidations.get(key);
|
|
1659
|
-
if (last !== void 0 && now - last <
|
|
1661
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1660
1662
|
recentValidations.set(key, now);
|
|
1661
1663
|
if (recentValidations.size > 50) {
|
|
1662
1664
|
for (const [k, ts] of recentValidations) {
|
|
1663
|
-
if (now - ts >
|
|
1665
|
+
if (now - ts > ttl) recentValidations.delete(k);
|
|
1664
1666
|
}
|
|
1665
1667
|
}
|
|
1666
1668
|
return false;
|
|
@@ -1699,16 +1701,16 @@ function installValidationCapture() {
|
|
|
1699
1701
|
__name(installValidationCapture, "installValidationCapture");
|
|
1700
1702
|
|
|
1701
1703
|
// src/client/capture/network.ts
|
|
1702
|
-
var NETWORK_DEDUP_TTL = 5e3;
|
|
1703
1704
|
var recentNetworkErrors = /* @__PURE__ */ new Map();
|
|
1704
1705
|
function isRecentNetwork(key) {
|
|
1706
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1705
1707
|
const now = Date.now();
|
|
1706
1708
|
const last = recentNetworkErrors.get(key);
|
|
1707
|
-
if (last !== void 0 && now - last <
|
|
1709
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1708
1710
|
recentNetworkErrors.set(key, now);
|
|
1709
1711
|
if (recentNetworkErrors.size > 100) {
|
|
1710
1712
|
for (const [k, ts] of recentNetworkErrors) {
|
|
1711
|
-
if (now - ts >
|
|
1713
|
+
if (now - ts > ttl) recentNetworkErrors.delete(k);
|
|
1712
1714
|
}
|
|
1713
1715
|
}
|
|
1714
1716
|
return false;
|