test
This commit is contained in:
@@ -81,6 +81,45 @@ cat <<'EOF'
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
window.__deployTestAuthState = async () => {
|
||||
const state = {
|
||||
href: window.location.href,
|
||||
hash: window.location.hash,
|
||||
userID: await window.__deployTestReadLocalForage("IM_USERID"),
|
||||
hasIMToken: Boolean(await window.__deployTestReadLocalForage("IM_TOKEN")),
|
||||
hasChatToken: Boolean(await window.__deployTestReadLocalForage("IM_CHAT_TOKEN")),
|
||||
counts: { ...counts },
|
||||
};
|
||||
console.log("[probe] auth state", state);
|
||||
return state;
|
||||
};
|
||||
if (!window.__deployTestXHRWrapped) {
|
||||
const originalOpen = XMLHttpRequest.prototype.open;
|
||||
const originalSend = XMLHttpRequest.prototype.send;
|
||||
XMLHttpRequest.prototype.open = function (method, url, ...args) {
|
||||
this.__deployTestRequest = { method, url, startedAt: Date.now() };
|
||||
return originalOpen.call(this, method, url, ...args);
|
||||
};
|
||||
XMLHttpRequest.prototype.send = function (...args) {
|
||||
const req = this.__deployTestRequest;
|
||||
if (req) {
|
||||
this.addEventListener("loadend", () => {
|
||||
if (String(req.url).includes("/account/login") || String(req.url).includes("/auth/get_user_token")) {
|
||||
console.log("[probe xhr]", {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
status: this.status,
|
||||
ms: Date.now() - req.startedAt,
|
||||
response: String(this.responseText || "").slice(0, 500),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return originalSend.apply(this, args);
|
||||
};
|
||||
window.__deployTestXHRWrapped = true;
|
||||
console.log("[probe] XMLHttpRequest: wrapped");
|
||||
}
|
||||
window.__deployTestListBrowserDBs = async () => {
|
||||
const dbs = indexedDB.databases ? await indexedDB.databases() : [];
|
||||
console.log("[probe] indexedDB databases", dbs);
|
||||
@@ -179,4 +218,8 @@ await window.__deployTestResetBrowserStorage()
|
||||
3. 重新粘贴本脚本输出的整段 JS(刷新会清掉已安装的 probe)
|
||||
4. 再登录
|
||||
5. 观察 counts 是否从 0 变 1,以及 /var/log/nginx/openim-pc-proxy-access.log 是否出现 /msg_gateway
|
||||
|
||||
如果 counts 仍为 0,查看业务登录链路状态:
|
||||
|
||||
await window.__deployTestAuthState()
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user