@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.d.cts
CHANGED
|
@@ -88,6 +88,10 @@ interface MonitorConfig {
|
|
|
88
88
|
captureJsErrors?: boolean;
|
|
89
89
|
/** Log debug info to console. Default: false */
|
|
90
90
|
debug?: boolean;
|
|
91
|
+
/** Deduplication TTL in ms for per-capture-source filtering. Default: 5000 */
|
|
92
|
+
dedupeTtl?: number;
|
|
93
|
+
/** Deduplication TTL in ms for the global store-level filter (cross-source). Default: 30000 */
|
|
94
|
+
dedupeStoreTtl?: number;
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
declare function monitoredFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
package/dist/client.d.ts
CHANGED
|
@@ -88,6 +88,10 @@ interface MonitorConfig {
|
|
|
88
88
|
captureJsErrors?: boolean;
|
|
89
89
|
/** Log debug info to console. Default: false */
|
|
90
90
|
debug?: boolean;
|
|
91
|
+
/** Deduplication TTL in ms for per-capture-source filtering. Default: 5000 */
|
|
92
|
+
dedupeTtl?: number;
|
|
93
|
+
/** Deduplication TTL in ms for the global store-level filter (cross-source). Default: 30000 */
|
|
94
|
+
dedupeStoreTtl?: number;
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
declare function monitoredFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
package/dist/client.mjs
CHANGED
|
@@ -1341,12 +1341,16 @@ __name(sendBatch, "sendBatch");
|
|
|
1341
1341
|
// src/client/utils/env.ts
|
|
1342
1342
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
1343
1343
|
var isProduction = !isDevelopment;
|
|
1344
|
-
var MONITOR_VERSION = "2.1.
|
|
1344
|
+
var MONITOR_VERSION = "2.1.240";
|
|
1345
|
+
|
|
1346
|
+
// src/client/constants.ts
|
|
1347
|
+
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|
|
1348
|
+
var DEFAULT_DEDUPE_TTL = 5e3;
|
|
1349
|
+
var DEFAULT_DEDUPE_STORE_TTL = 3e4;
|
|
1345
1350
|
|
|
1346
1351
|
// src/client/store/index.ts
|
|
1347
1352
|
var CIRCUIT_BREAKER_THRESHOLD = 3;
|
|
1348
1353
|
var CIRCUIT_BREAKER_COOLDOWN_MS = 6e4;
|
|
1349
|
-
var STORE_DEDUP_TTL = 5e3;
|
|
1350
1354
|
var STORE_DEDUP_MAX = 200;
|
|
1351
1355
|
var _recentPushKeys = /* @__PURE__ */ new Map();
|
|
1352
1356
|
function _pushDedupeKey(event) {
|
|
@@ -1354,14 +1358,14 @@ function _pushDedupeKey(event) {
|
|
|
1354
1358
|
return `${event.event_type}:${event.level}:${msg}:${event.http_url ?? event.url ?? ""}`;
|
|
1355
1359
|
}
|
|
1356
1360
|
__name(_pushDedupeKey, "_pushDedupeKey");
|
|
1357
|
-
function _isRecentPush(key) {
|
|
1361
|
+
function _isRecentPush(key, ttl) {
|
|
1358
1362
|
const now = Date.now();
|
|
1359
1363
|
const last = _recentPushKeys.get(key);
|
|
1360
|
-
if (last !== void 0 && now - last <
|
|
1364
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1361
1365
|
_recentPushKeys.set(key, now);
|
|
1362
1366
|
if (_recentPushKeys.size > STORE_DEDUP_MAX) {
|
|
1363
1367
|
for (const [k, ts] of _recentPushKeys) {
|
|
1364
|
-
if (now - ts >
|
|
1368
|
+
if (now - ts > ttl) _recentPushKeys.delete(k);
|
|
1365
1369
|
}
|
|
1366
1370
|
}
|
|
1367
1371
|
return false;
|
|
@@ -1374,9 +1378,10 @@ var monitorStore = createStore((set, get) => ({
|
|
|
1374
1378
|
_consecutiveFailures: 0,
|
|
1375
1379
|
_pausedUntil: 0,
|
|
1376
1380
|
push(event) {
|
|
1377
|
-
const dedupeKey = _pushDedupeKey(event);
|
|
1378
|
-
if (_isRecentPush(dedupeKey)) return;
|
|
1379
1381
|
const { config, buffer } = get();
|
|
1382
|
+
const storeTtl = config.dedupeStoreTtl ?? DEFAULT_DEDUPE_STORE_TTL;
|
|
1383
|
+
const dedupeKey = _pushDedupeKey(event);
|
|
1384
|
+
if (_isRecentPush(dedupeKey, storeTtl)) return;
|
|
1380
1385
|
const maxSize = config.maxBufferSize ?? 20;
|
|
1381
1386
|
const sanitized = {
|
|
1382
1387
|
build_id: event.build_id ?? config.buildId ?? `sdk:${MONITOR_VERSION}`,
|
|
@@ -1404,8 +1409,8 @@ var monitorStore = createStore((set, get) => ({
|
|
|
1404
1409
|
const { buffer, _pausedUntil } = get();
|
|
1405
1410
|
if (buffer.length === 0) return;
|
|
1406
1411
|
if (Date.now() < _pausedUntil) return;
|
|
1407
|
-
const batch = buffer.slice(0,
|
|
1408
|
-
set({ buffer: buffer.slice(
|
|
1412
|
+
const batch = buffer.slice(0, 25);
|
|
1413
|
+
set({ buffer: buffer.slice(25) });
|
|
1409
1414
|
sendBatch({ events: batch }, useBeacon).then(
|
|
1410
1415
|
() => {
|
|
1411
1416
|
set({ _consecutiveFailures: 0, _pausedUntil: 0 });
|
|
@@ -1422,9 +1427,6 @@ var monitorStore = createStore((set, get) => ({
|
|
|
1422
1427
|
}
|
|
1423
1428
|
}));
|
|
1424
1429
|
|
|
1425
|
-
// src/client/constants.ts
|
|
1426
|
-
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|
|
1427
|
-
|
|
1428
1430
|
// src/client/capture/js-errors.ts
|
|
1429
1431
|
var MSG_MAX = 2e3;
|
|
1430
1432
|
function truncate(s, max = MSG_MAX) {
|
|
@@ -1447,12 +1449,12 @@ function isHydrationNoise(msg) {
|
|
|
1447
1449
|
return HYDRATION_NOISE.some((p) => p.test(msg));
|
|
1448
1450
|
}
|
|
1449
1451
|
__name(isHydrationNoise, "isHydrationNoise");
|
|
1450
|
-
var CLIENT_DEDUP_TTL = 5 * 60 * 1e3;
|
|
1451
1452
|
var recentFingerprints = /* @__PURE__ */ new Map();
|
|
1452
1453
|
function isRecentlySent(fingerprint) {
|
|
1454
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1453
1455
|
const now = Date.now();
|
|
1454
1456
|
const last = recentFingerprints.get(fingerprint);
|
|
1455
|
-
if (last !== void 0 && now - last <
|
|
1457
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1456
1458
|
recentFingerprints.set(fingerprint, now);
|
|
1457
1459
|
if (recentFingerprints.size > 100) {
|
|
1458
1460
|
const oldest = [...recentFingerprints.entries()].sort((a, b) => a[1] - b[1])[0];
|
|
@@ -1537,12 +1539,12 @@ var typeMap = {
|
|
|
1537
1539
|
error: "ERROR" /* ERROR */
|
|
1538
1540
|
};
|
|
1539
1541
|
var ARG_MAX = 500;
|
|
1540
|
-
var CONSOLE_DEDUP_TTL = 5 * 60 * 1e3;
|
|
1541
1542
|
var recentConsoleFingerprints = /* @__PURE__ */ new Map();
|
|
1542
1543
|
function isRecentConsole(fingerprint) {
|
|
1544
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1543
1545
|
const now = Date.now();
|
|
1544
1546
|
const last = recentConsoleFingerprints.get(fingerprint);
|
|
1545
|
-
if (last !== void 0 && now - last <
|
|
1547
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1546
1548
|
recentConsoleFingerprints.set(fingerprint, now);
|
|
1547
1549
|
if (recentConsoleFingerprints.size > 100) {
|
|
1548
1550
|
const oldest = [...recentConsoleFingerprints.entries()].sort((a, b) => a[1] - b[1])[0];
|
|
@@ -1628,16 +1630,16 @@ function installConsoleCapture() {
|
|
|
1628
1630
|
__name(installConsoleCapture, "installConsoleCapture");
|
|
1629
1631
|
|
|
1630
1632
|
// src/client/capture/validation.ts
|
|
1631
|
-
var VALIDATION_DEDUP_TTL = 1e4;
|
|
1632
1633
|
var recentValidations = /* @__PURE__ */ new Map();
|
|
1633
1634
|
function isRecentValidation(key) {
|
|
1635
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1634
1636
|
const now = Date.now();
|
|
1635
1637
|
const last = recentValidations.get(key);
|
|
1636
|
-
if (last !== void 0 && now - last <
|
|
1638
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1637
1639
|
recentValidations.set(key, now);
|
|
1638
1640
|
if (recentValidations.size > 50) {
|
|
1639
1641
|
for (const [k, ts] of recentValidations) {
|
|
1640
|
-
if (now - ts >
|
|
1642
|
+
if (now - ts > ttl) recentValidations.delete(k);
|
|
1641
1643
|
}
|
|
1642
1644
|
}
|
|
1643
1645
|
return false;
|
|
@@ -1676,16 +1678,16 @@ function installValidationCapture() {
|
|
|
1676
1678
|
__name(installValidationCapture, "installValidationCapture");
|
|
1677
1679
|
|
|
1678
1680
|
// src/client/capture/network.ts
|
|
1679
|
-
var NETWORK_DEDUP_TTL = 5e3;
|
|
1680
1681
|
var recentNetworkErrors = /* @__PURE__ */ new Map();
|
|
1681
1682
|
function isRecentNetwork(key) {
|
|
1683
|
+
const ttl = monitorStore.getState().config.dedupeTtl ?? DEFAULT_DEDUPE_TTL;
|
|
1682
1684
|
const now = Date.now();
|
|
1683
1685
|
const last = recentNetworkErrors.get(key);
|
|
1684
|
-
if (last !== void 0 && now - last <
|
|
1686
|
+
if (last !== void 0 && now - last < ttl) return true;
|
|
1685
1687
|
recentNetworkErrors.set(key, now);
|
|
1686
1688
|
if (recentNetworkErrors.size > 100) {
|
|
1687
1689
|
for (const [k, ts] of recentNetworkErrors) {
|
|
1688
|
-
if (now - ts >
|
|
1690
|
+
if (now - ts > ttl) recentNetworkErrors.delete(k);
|
|
1689
1691
|
}
|
|
1690
1692
|
}
|
|
1691
1693
|
return false;
|