@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.cjs
CHANGED
|
@@ -269,8 +269,11 @@ __export(client_exports, {
|
|
|
269
269
|
MonitorProvider: () => MonitorProvider,
|
|
270
270
|
getSessionId: () => getSessionId,
|
|
271
271
|
initWindowMonitor: () => initWindowMonitor,
|
|
272
|
+
isDevelopment: () => isDevelopment,
|
|
273
|
+
isProduction: () => isProduction,
|
|
272
274
|
monitorStore: () => monitorStore,
|
|
273
|
-
monitoredFetch: () => monitoredFetch
|
|
275
|
+
monitoredFetch: () => monitoredFetch,
|
|
276
|
+
useDebugMode: () => useDebugMode
|
|
274
277
|
});
|
|
275
278
|
module.exports = __toCommonJS(client_exports);
|
|
276
279
|
|
|
@@ -1749,6 +1752,57 @@ function MonitorProvider({ children, ...config }) {
|
|
|
1749
1752
|
}
|
|
1750
1753
|
__name(MonitorProvider, "MonitorProvider");
|
|
1751
1754
|
|
|
1755
|
+
// src/client/hooks/useDebugMode.ts
|
|
1756
|
+
var import_react2 = require("react");
|
|
1757
|
+
|
|
1758
|
+
// src/client/utils/env.ts
|
|
1759
|
+
var isDevelopment = true;
|
|
1760
|
+
var isProduction = false;
|
|
1761
|
+
|
|
1762
|
+
// src/client/hooks/useDebugMode.ts
|
|
1763
|
+
var LS_KEY = "__debug_mode__";
|
|
1764
|
+
function readFromStorage() {
|
|
1765
|
+
try {
|
|
1766
|
+
return localStorage.getItem(LS_KEY) === "1";
|
|
1767
|
+
} catch {
|
|
1768
|
+
return false;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
__name(readFromStorage, "readFromStorage");
|
|
1772
|
+
function persistToStorage() {
|
|
1773
|
+
try {
|
|
1774
|
+
localStorage.setItem(LS_KEY, "1");
|
|
1775
|
+
} catch {
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
__name(persistToStorage, "persistToStorage");
|
|
1779
|
+
function consumeDebugParam() {
|
|
1780
|
+
if (typeof window === "undefined") return false;
|
|
1781
|
+
const params = new URLSearchParams(window.location.search);
|
|
1782
|
+
const value = params.get("debug");
|
|
1783
|
+
if (!value) return false;
|
|
1784
|
+
persistToStorage();
|
|
1785
|
+
params.delete("debug");
|
|
1786
|
+
const newUrl = `${window.location.pathname}${params.toString() ? `?${params.toString()}` : ""}${window.location.hash}`;
|
|
1787
|
+
window.history.replaceState(null, "", newUrl);
|
|
1788
|
+
return true;
|
|
1789
|
+
}
|
|
1790
|
+
__name(consumeDebugParam, "consumeDebugParam");
|
|
1791
|
+
function useDebugMode() {
|
|
1792
|
+
if (isDevelopment) return true;
|
|
1793
|
+
const [isDebug, setIsDebug] = (0, import_react2.useState)(false);
|
|
1794
|
+
(0, import_react2.useEffect)(() => {
|
|
1795
|
+
const fromUrl = consumeDebugParam();
|
|
1796
|
+
if (fromUrl) {
|
|
1797
|
+
setIsDebug(true);
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
setIsDebug(readFromStorage());
|
|
1801
|
+
}, []);
|
|
1802
|
+
return isDebug;
|
|
1803
|
+
}
|
|
1804
|
+
__name(useDebugMode, "useDebugMode");
|
|
1805
|
+
|
|
1752
1806
|
// src/client/index.ts
|
|
1753
1807
|
var flushInterval = null;
|
|
1754
1808
|
var cleanupFns = [];
|