This commit is contained in:
vet
2026-04-14 12:25:18 +07:00
parent fdb9679577
commit 04cd3e2b4b

View File

@@ -6,13 +6,16 @@ cat <<'EOF'
(() => { (() => {
const stamp = () => new Date().toISOString(); const stamp = () => new Date().toISOString();
const counts = {};
const wrap = (name) => { const wrap = (name) => {
const original = window[name]; const original = window[name];
if (typeof original !== "function" || original.__deployTestProbe) { if (typeof original !== "function") {
console.log(`[probe] ${name}:`, typeof original); console.log(`[probe] ${name}:`, typeof original);
return; return;
} }
counts[name] = 0;
const wrapped = function (...args) { const wrapped = function (...args) {
counts[name] += 1;
console.log(`[probe ${stamp()}] ${name} called`, args); console.log(`[probe ${stamp()}] ${name} called`, args);
try { try {
const ret = original.apply(this, args); const ret = original.apply(this, args);
@@ -24,7 +27,9 @@ cat <<'EOF'
} }
}; };
wrapped.__deployTestProbe = true; wrapped.__deployTestProbe = true;
wrapped.__deployTestOriginal = original;
window[name] = wrapped; window[name] = wrapped;
console.log(`[probe] ${name}: wrapped`);
}; };
["initSDK", "login", "commonEventFunc"].forEach(wrap); ["initSDK", "login", "commonEventFunc"].forEach(wrap);
@@ -42,10 +47,16 @@ cat <<'EOF'
commonEventFunc: typeof window.commonEventFunc, commonEventFunc: typeof window.commonEventFunc,
openIMRenderApi: typeof window.openIMRenderApi, openIMRenderApi: typeof window.openIMRenderApi,
}); });
window.__deployTestProbeCounts = counts;
clearInterval(window.__deployTestProbeTimer);
window.__deployTestProbeTimer = setInterval(() => {
console.log(`[probe ${stamp()}] counts`, { ...counts });
}, 5000);
})(); })();
然后退出登录/刷新页面重新登录一次,观察是否打印: 然后退出登录/刷新页面重新登录一次,观察是否打印:
- initSDK called / returned - initSDK called / returned
- login called / returned - login called / returned
- window error / unhandledrejection - window error / unhandledrejection
- counts 里的 initSDK/login 是否从 0 变成 1
EOF EOF