Skip to content

Commit 2fd171f

Browse files
author
Herve Tribouilloy
committed
feat(debug): scope observability to specific widgets via re-debug query param
Observability is now activated only when explicitly targeting a widget (e.g. ?re-debug=banner) or using ?re-debug=all. Removes global debug activation and aligns logging with widget isolation model.
1 parent 4567996 commit 2fd171f

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
export const isActivityEnabled = () =>
2-
window.__REACTEDGE_DEBUG__ === true ||
3-
new URLSearchParams(window.location.search).has('re-debug');
1+
import {WIDGET_ID} from "../mountWidget.tsx";
2+
3+
const debugTargets = getDebugTargets();
4+
5+
function getDebugTargets(): string[] | null {
6+
const params = new URLSearchParams(window.location.search);
7+
const value = params.get('re-debug');
8+
9+
if (!value) return null;
10+
11+
if (value === "1" || value === "all") return ["all"];
12+
13+
return value.split(",").map(v => v.trim().toLowerCase());
14+
}
15+
16+
export const isActivityEnabled = () => debugTargets &&
17+
(debugTargets.includes("all") || debugTargets.includes(WIDGET_ID));

vite_project/src/activity/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function activity(
1919
ts: Date.now(),
2020
};
2121

22-
const prefix = `${phase}`;
22+
const prefix = `[${WIDGET_ID}] ${phase}`;
2323

2424
if (level === 'error') {
2525
console.error(prefix, payload);

0 commit comments

Comments
 (0)