feat(customers): opt-in debug block on the omde lists, printed in the panel console

Sending X-Debug: 1 makes the five wholesale list endpoints return a counts-only
`debug` block next to the rows: the WHERE that actually ran, how many customers
the scope matches before the grid's own filters, how many customers exist per
kind/active/archived/step and how many are an expert's trading account. The
panel sends the header and console-logs the block when localStorage.debug === '1'.

Off by default; DIAG_LOG=false disables it server-side. No names or mobiles.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mahmood
2026-10-26 08:59:33 +03:30
co-authored by Claude Sonnet 5.5
parent ab39f6abed
commit 0156a976e7
4 changed files with 113 additions and 16 deletions
+15 -1
View File
@@ -52,6 +52,11 @@ ax.interceptors.request.use(
if (config.data instanceof FormData) {
delete config.headers['Content-Type'];
}
// Opt-in troubleshooting: run `localStorage.setItem('debug', '1')` in the
// console and reload; list endpoints then answer with a `debug` block.
if (localStorage.getItem('debug') === '1') {
config.headers['X-Debug'] = '1';
}
return config;
},
(error) => Promise.reject(error),
@@ -67,7 +72,16 @@ ax.interceptors.request.use(
*/
let redirecting = false;
ax.interceptors.response.use(
(response) => response,
(response) => {
const debug = response.data?.debug;
if (debug && localStorage.getItem('debug') === '1') {
console.groupCollapsed(`[DEBUG] ${response.config.url}`);
console.log(debug);
if (Array.isArray(debug.by_kind)) console.table(debug.by_kind);
console.groupEnd();
}
return response;
},
(error) => {
if (error?.response?.status === 401 && !redirecting) {
const onLoginPage = window.location.pathname.endsWith('/auth/login');