@djangocfg/monitor 2.1.230 → 2.1.231
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/README.md +16 -1
- package/dist/client.cjs +26 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -1
- package/dist/client.d.ts +3 -1
- package/dist/client.mjs +26 -12
- package/dist/client.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client/hooks/useDebugMode.ts +21 -7
- package/src/client/index.ts +1 -1
- package/src/client/store/index.ts +2 -0
- package/src/client/utils/env.ts +3 -0
- package/src/client/window.ts +3 -0
package/dist/client.d.cts
CHANGED
|
@@ -163,6 +163,8 @@ declare function useDebugMode(): boolean;
|
|
|
163
163
|
declare const isDevelopment: boolean;
|
|
164
164
|
/** True in production builds and test environments */
|
|
165
165
|
declare const isProduction: boolean;
|
|
166
|
+
/** Package version — injected at build time via tsup define, falls back to package.json value */
|
|
167
|
+
declare const MONITOR_VERSION: string;
|
|
166
168
|
|
|
167
169
|
/**
|
|
168
170
|
* @djangocfg/monitor/client
|
|
@@ -192,4 +194,4 @@ declare const FrontendMonitor: {
|
|
|
192
194
|
destroy(): void;
|
|
193
195
|
};
|
|
194
196
|
|
|
195
|
-
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, isDevelopment, isProduction, monitorStore, monitoredFetch, useDebugMode };
|
|
197
|
+
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, MONITOR_VERSION, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, isDevelopment, isProduction, monitorStore, monitoredFetch, useDebugMode };
|
package/dist/client.d.ts
CHANGED
|
@@ -163,6 +163,8 @@ declare function useDebugMode(): boolean;
|
|
|
163
163
|
declare const isDevelopment: boolean;
|
|
164
164
|
/** True in production builds and test environments */
|
|
165
165
|
declare const isProduction: boolean;
|
|
166
|
+
/** Package version — injected at build time via tsup define, falls back to package.json value */
|
|
167
|
+
declare const MONITOR_VERSION: string;
|
|
166
168
|
|
|
167
169
|
/**
|
|
168
170
|
* @djangocfg/monitor/client
|
|
@@ -192,4 +194,4 @@ declare const FrontendMonitor: {
|
|
|
192
194
|
destroy(): void;
|
|
193
195
|
};
|
|
194
196
|
|
|
195
|
-
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, isDevelopment, isProduction, monitorStore, monitoredFetch, useDebugMode };
|
|
197
|
+
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, MONITOR_VERSION, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, isDevelopment, isProduction, monitorStore, monitoredFetch, useDebugMode };
|
package/dist/client.mjs
CHANGED
|
@@ -1334,6 +1334,11 @@ async function sendBatch(batch, useBeacon = false) {
|
|
|
1334
1334
|
}
|
|
1335
1335
|
__name(sendBatch, "sendBatch");
|
|
1336
1336
|
|
|
1337
|
+
// src/client/utils/env.ts
|
|
1338
|
+
var isDevelopment = true;
|
|
1339
|
+
var isProduction = false;
|
|
1340
|
+
var MONITOR_VERSION = "2.1.231";
|
|
1341
|
+
|
|
1337
1342
|
// src/client/store/index.ts
|
|
1338
1343
|
var CIRCUIT_BREAKER_THRESHOLD = 3;
|
|
1339
1344
|
var CIRCUIT_BREAKER_COOLDOWN_MS = 6e4;
|
|
@@ -1347,6 +1352,7 @@ var monitorStore = createStore((set, get) => ({
|
|
|
1347
1352
|
const { config, buffer } = get();
|
|
1348
1353
|
const maxSize = config.maxBufferSize ?? 20;
|
|
1349
1354
|
const sanitized = {
|
|
1355
|
+
build_id: event.build_id ?? config.buildId ?? `sdk:${MONITOR_VERSION}`,
|
|
1350
1356
|
...event,
|
|
1351
1357
|
// Enforce field size limits before buffering (last-resort backstop)
|
|
1352
1358
|
message: event.message && event.message.length > 4997 ? event.message.slice(0, 4997) + "..." : event.message,
|
|
@@ -1708,6 +1714,8 @@ function initWindowMonitor() {
|
|
|
1708
1714
|
status() {
|
|
1709
1715
|
const state = monitorStore.getState();
|
|
1710
1716
|
console.group("[monitor] status");
|
|
1717
|
+
console.log("sdk version:", MONITOR_VERSION);
|
|
1718
|
+
console.log("build_id:", state.config.buildId ?? `sdk:${MONITOR_VERSION}`);
|
|
1711
1719
|
console.log("config:", state.config);
|
|
1712
1720
|
console.log("buffer size:", state.buffer.length);
|
|
1713
1721
|
console.log("initialized:", state.initialized);
|
|
@@ -1732,12 +1740,6 @@ __name(MonitorProvider, "MonitorProvider");
|
|
|
1732
1740
|
|
|
1733
1741
|
// src/client/hooks/useDebugMode.ts
|
|
1734
1742
|
import { useEffect as useEffect2, useState } from "react";
|
|
1735
|
-
|
|
1736
|
-
// src/client/utils/env.ts
|
|
1737
|
-
var isDevelopment = true;
|
|
1738
|
-
var isProduction = false;
|
|
1739
|
-
|
|
1740
|
-
// src/client/hooks/useDebugMode.ts
|
|
1741
1743
|
var LS_KEY = "__debug_mode__";
|
|
1742
1744
|
function readFromStorage() {
|
|
1743
1745
|
try {
|
|
@@ -1754,16 +1756,27 @@ function persistToStorage() {
|
|
|
1754
1756
|
}
|
|
1755
1757
|
}
|
|
1756
1758
|
__name(persistToStorage, "persistToStorage");
|
|
1759
|
+
function clearFromStorage() {
|
|
1760
|
+
try {
|
|
1761
|
+
localStorage.removeItem(LS_KEY);
|
|
1762
|
+
} catch {
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
__name(clearFromStorage, "clearFromStorage");
|
|
1757
1766
|
function consumeDebugParam() {
|
|
1758
|
-
if (typeof window === "undefined") return
|
|
1767
|
+
if (typeof window === "undefined") return null;
|
|
1759
1768
|
const params = new URLSearchParams(window.location.search);
|
|
1760
1769
|
const value = params.get("debug");
|
|
1761
|
-
if (
|
|
1762
|
-
|
|
1770
|
+
if (value === null) return null;
|
|
1771
|
+
if (value === "1") {
|
|
1772
|
+
persistToStorage();
|
|
1773
|
+
} else {
|
|
1774
|
+
clearFromStorage();
|
|
1775
|
+
}
|
|
1763
1776
|
params.delete("debug");
|
|
1764
1777
|
const newUrl = `${window.location.pathname}${params.toString() ? `?${params.toString()}` : ""}${window.location.hash}`;
|
|
1765
1778
|
window.history.replaceState(null, "", newUrl);
|
|
1766
|
-
return
|
|
1779
|
+
return value === "1";
|
|
1767
1780
|
}
|
|
1768
1781
|
__name(consumeDebugParam, "consumeDebugParam");
|
|
1769
1782
|
function useDebugMode() {
|
|
@@ -1771,8 +1784,8 @@ function useDebugMode() {
|
|
|
1771
1784
|
const [isDebug, setIsDebug] = useState(false);
|
|
1772
1785
|
useEffect2(() => {
|
|
1773
1786
|
const fromUrl = consumeDebugParam();
|
|
1774
|
-
if (fromUrl) {
|
|
1775
|
-
setIsDebug(
|
|
1787
|
+
if (fromUrl !== null) {
|
|
1788
|
+
setIsDebug(fromUrl);
|
|
1776
1789
|
return;
|
|
1777
1790
|
}
|
|
1778
1791
|
setIsDebug(readFromStorage());
|
|
@@ -1822,6 +1835,7 @@ export {
|
|
|
1822
1835
|
FrontendEventIngestRequestLevel as EventLevel,
|
|
1823
1836
|
FrontendEventIngestRequestEventType as EventType,
|
|
1824
1837
|
FrontendMonitor,
|
|
1838
|
+
MONITOR_VERSION,
|
|
1825
1839
|
MonitorProvider,
|
|
1826
1840
|
getSessionId,
|
|
1827
1841
|
initWindowMonitor,
|