@djangocfg/monitor 2.1.229 → 2.1.230
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 +55 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +15 -1
- package/dist/client.d.ts +15 -1
- package/dist/client.mjs +55 -1
- package/dist/client.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client/hooks/useDebugMode.ts +70 -0
- package/src/client/index.ts +2 -0
- package/src/client/utils/env.ts +13 -0
package/dist/client.d.cts
CHANGED
|
@@ -150,6 +150,20 @@ interface MonitorState {
|
|
|
150
150
|
}
|
|
151
151
|
declare const monitorStore: zustand_vanilla.StoreApi<MonitorState>;
|
|
152
152
|
|
|
153
|
+
declare function useDebugMode(): boolean;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Environment utilities.
|
|
157
|
+
*
|
|
158
|
+
* Use these constants instead of inline process.env.NODE_ENV checks.
|
|
159
|
+
* Webpack/esbuild replaces process.env.NODE_ENV statically at build time,
|
|
160
|
+
* so these are zero-cost — they tree-shake correctly in both client and server bundles.
|
|
161
|
+
*/
|
|
162
|
+
/** True only in `next dev` / jest / vitest */
|
|
163
|
+
declare const isDevelopment: boolean;
|
|
164
|
+
/** True in production builds and test environments */
|
|
165
|
+
declare const isProduction: boolean;
|
|
166
|
+
|
|
153
167
|
/**
|
|
154
168
|
* @djangocfg/monitor/client
|
|
155
169
|
*
|
|
@@ -178,4 +192,4 @@ declare const FrontendMonitor: {
|
|
|
178
192
|
destroy(): void;
|
|
179
193
|
};
|
|
180
194
|
|
|
181
|
-
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, monitorStore, monitoredFetch };
|
|
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 };
|
package/dist/client.d.ts
CHANGED
|
@@ -150,6 +150,20 @@ interface MonitorState {
|
|
|
150
150
|
}
|
|
151
151
|
declare const monitorStore: zustand_vanilla.StoreApi<MonitorState>;
|
|
152
152
|
|
|
153
|
+
declare function useDebugMode(): boolean;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Environment utilities.
|
|
157
|
+
*
|
|
158
|
+
* Use these constants instead of inline process.env.NODE_ENV checks.
|
|
159
|
+
* Webpack/esbuild replaces process.env.NODE_ENV statically at build time,
|
|
160
|
+
* so these are zero-cost — they tree-shake correctly in both client and server bundles.
|
|
161
|
+
*/
|
|
162
|
+
/** True only in `next dev` / jest / vitest */
|
|
163
|
+
declare const isDevelopment: boolean;
|
|
164
|
+
/** True in production builds and test environments */
|
|
165
|
+
declare const isProduction: boolean;
|
|
166
|
+
|
|
153
167
|
/**
|
|
154
168
|
* @djangocfg/monitor/client
|
|
155
169
|
*
|
|
@@ -178,4 +192,4 @@ declare const FrontendMonitor: {
|
|
|
178
192
|
destroy(): void;
|
|
179
193
|
};
|
|
180
194
|
|
|
181
|
-
export { FrontendEventIngestRequestLevel as EventLevel, FrontendEventIngestRequestEventType as EventType, FrontendMonitor, type MonitorConfig, type FrontendEventIngestRequest as MonitorEvent, MonitorProvider, type MonitorProviderProps, type WindowMonitorAPI, getSessionId, initWindowMonitor, monitorStore, monitoredFetch };
|
|
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 };
|
package/dist/client.mjs
CHANGED
|
@@ -1730,6 +1730,57 @@ function MonitorProvider({ children, ...config }) {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
__name(MonitorProvider, "MonitorProvider");
|
|
1732
1732
|
|
|
1733
|
+
// src/client/hooks/useDebugMode.ts
|
|
1734
|
+
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
|
+
var LS_KEY = "__debug_mode__";
|
|
1742
|
+
function readFromStorage() {
|
|
1743
|
+
try {
|
|
1744
|
+
return localStorage.getItem(LS_KEY) === "1";
|
|
1745
|
+
} catch {
|
|
1746
|
+
return false;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
__name(readFromStorage, "readFromStorage");
|
|
1750
|
+
function persistToStorage() {
|
|
1751
|
+
try {
|
|
1752
|
+
localStorage.setItem(LS_KEY, "1");
|
|
1753
|
+
} catch {
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
__name(persistToStorage, "persistToStorage");
|
|
1757
|
+
function consumeDebugParam() {
|
|
1758
|
+
if (typeof window === "undefined") return false;
|
|
1759
|
+
const params = new URLSearchParams(window.location.search);
|
|
1760
|
+
const value = params.get("debug");
|
|
1761
|
+
if (!value) return false;
|
|
1762
|
+
persistToStorage();
|
|
1763
|
+
params.delete("debug");
|
|
1764
|
+
const newUrl = `${window.location.pathname}${params.toString() ? `?${params.toString()}` : ""}${window.location.hash}`;
|
|
1765
|
+
window.history.replaceState(null, "", newUrl);
|
|
1766
|
+
return true;
|
|
1767
|
+
}
|
|
1768
|
+
__name(consumeDebugParam, "consumeDebugParam");
|
|
1769
|
+
function useDebugMode() {
|
|
1770
|
+
if (isDevelopment) return true;
|
|
1771
|
+
const [isDebug, setIsDebug] = useState(false);
|
|
1772
|
+
useEffect2(() => {
|
|
1773
|
+
const fromUrl = consumeDebugParam();
|
|
1774
|
+
if (fromUrl) {
|
|
1775
|
+
setIsDebug(true);
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
setIsDebug(readFromStorage());
|
|
1779
|
+
}, []);
|
|
1780
|
+
return isDebug;
|
|
1781
|
+
}
|
|
1782
|
+
__name(useDebugMode, "useDebugMode");
|
|
1783
|
+
|
|
1733
1784
|
// src/client/index.ts
|
|
1734
1785
|
var flushInterval = null;
|
|
1735
1786
|
var cleanupFns = [];
|
|
@@ -1774,7 +1825,10 @@ export {
|
|
|
1774
1825
|
MonitorProvider,
|
|
1775
1826
|
getSessionId,
|
|
1776
1827
|
initWindowMonitor,
|
|
1828
|
+
isDevelopment,
|
|
1829
|
+
isProduction,
|
|
1777
1830
|
monitorStore,
|
|
1778
|
-
monitoredFetch
|
|
1831
|
+
monitoredFetch,
|
|
1832
|
+
useDebugMode
|
|
1779
1833
|
};
|
|
1780
1834
|
//# sourceMappingURL=client.mjs.map
|