pref: 删除微信登陆日志
This commit is contained in:
@@ -129,12 +129,8 @@ export default function WechatRegister() {
|
|||||||
*/
|
*/
|
||||||
const handleLoginSuccess = useCallback(async (sessionId, status) => {
|
const handleLoginSuccess = useCallback(async (sessionId, status) => {
|
||||||
try {
|
try {
|
||||||
logger.info('WechatRegister', '开始调用登录接口', { sessionId: sessionId.substring(0, 8) + '...', status });
|
|
||||||
|
|
||||||
const response = await authService.loginWithWechat(sessionId);
|
const response = await authService.loginWithWechat(sessionId);
|
||||||
|
|
||||||
logger.info('WechatRegister', '登录接口返回', { success: response?.success, hasUser: !!response?.user });
|
|
||||||
|
|
||||||
if (response?.success) {
|
if (response?.success) {
|
||||||
// 追踪微信登录成功
|
// 追踪微信登录成功
|
||||||
authEvents.trackLoginSuccess(
|
authEvents.trackLoginSuccess(
|
||||||
@@ -183,33 +179,20 @@ export default function WechatRegister() {
|
|||||||
const checkWechatStatus = useCallback(async () => {
|
const checkWechatStatus = useCallback(async () => {
|
||||||
// 检查组件是否已卸载,使用 ref 获取最新的 sessionId
|
// 检查组件是否已卸载,使用 ref 获取最新的 sessionId
|
||||||
if (!isMountedRef.current || !sessionIdRef.current) {
|
if (!isMountedRef.current || !sessionIdRef.current) {
|
||||||
logger.debug('WechatRegister', 'checkWechatStatus 跳过', {
|
|
||||||
isMounted: isMountedRef.current,
|
|
||||||
hasSessionId: !!sessionIdRef.current
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentSessionId = sessionIdRef.current;
|
const currentSessionId = sessionIdRef.current;
|
||||||
logger.debug('WechatRegister', '检查微信状态', { sessionId: currentSessionId });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await authService.checkWechatStatus(currentSessionId);
|
const response = await authService.checkWechatStatus(currentSessionId);
|
||||||
|
|
||||||
// 安全检查:确保 response 存在且包含 status
|
// 安全检查:确保 response 存在且包含 status
|
||||||
if (!response || typeof response.status === 'undefined') {
|
if (!response || typeof response.status === 'undefined') {
|
||||||
logger.warn('WechatRegister', '微信状态检查返回无效数据', { response });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { status } = response;
|
const { status } = response;
|
||||||
logger.debug('WechatRegister', '微信状态', { status });
|
|
||||||
|
|
||||||
logger.debug('WechatRegister', '检测到微信状态', {
|
|
||||||
sessionId: wechatSessionId.substring(0, 8) + '...',
|
|
||||||
status,
|
|
||||||
userInfo: response.user_info
|
|
||||||
});
|
|
||||||
|
|
||||||
// 组件卸载后不再更新状态
|
// 组件卸载后不再更新状态
|
||||||
if (!isMountedRef.current) return;
|
if (!isMountedRef.current) return;
|
||||||
@@ -229,7 +212,6 @@ export default function WechatRegister() {
|
|||||||
|
|
||||||
// 处理成功状态
|
// 处理成功状态
|
||||||
if (status === WECHAT_STATUS.LOGIN_SUCCESS || status === WECHAT_STATUS.REGISTER_SUCCESS) {
|
if (status === WECHAT_STATUS.LOGIN_SUCCESS || status === WECHAT_STATUS.REGISTER_SUCCESS) {
|
||||||
logger.info('WechatRegister', '检测到登录成功状态,停止轮询', { status });
|
|
||||||
clearTimers(); // 停止轮询
|
clearTimers(); // 停止轮询
|
||||||
sessionIdRef.current = null; // 清理 sessionId
|
sessionIdRef.current = null; // 清理 sessionId
|
||||||
|
|
||||||
@@ -281,7 +263,6 @@ export default function WechatRegister() {
|
|||||||
}
|
}
|
||||||
// 处理授权成功(AUTHORIZED)- 用户已在微信端确认授权,调用登录 API
|
// 处理授权成功(AUTHORIZED)- 用户已在微信端确认授权,调用登录 API
|
||||||
else if (status === WECHAT_STATUS.AUTHORIZED) {
|
else if (status === WECHAT_STATUS.AUTHORIZED) {
|
||||||
logger.info('WechatRegister', '微信授权成功,调用登录 API', { sessionId: currentSessionId.substring(0, 8) + '...' });
|
|
||||||
clearTimers();
|
clearTimers();
|
||||||
sessionIdRef.current = null; // 清理 sessionId
|
sessionIdRef.current = null; // 清理 sessionId
|
||||||
await handleLoginSuccess(currentSessionId, status);
|
await handleLoginSuccess(currentSessionId, status);
|
||||||
@@ -310,11 +291,6 @@ export default function WechatRegister() {
|
|||||||
* 启动轮询
|
* 启动轮询
|
||||||
*/
|
*/
|
||||||
const startPolling = useCallback(() => {
|
const startPolling = useCallback(() => {
|
||||||
logger.debug('WechatRegister', '启动轮询', {
|
|
||||||
sessionId: sessionIdRef.current,
|
|
||||||
interval: POLL_INTERVAL
|
|
||||||
});
|
|
||||||
|
|
||||||
// 清理旧的定时器
|
// 清理旧的定时器
|
||||||
clearTimers();
|
clearTimers();
|
||||||
|
|
||||||
@@ -325,7 +301,6 @@ export default function WechatRegister() {
|
|||||||
|
|
||||||
// 设置超时
|
// 设置超时
|
||||||
timeoutRef.current = setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
logger.debug('WechatRegister', '二维码超时');
|
|
||||||
clearTimers();
|
clearTimers();
|
||||||
sessionIdRef.current = null; // 清理 sessionId
|
sessionIdRef.current = null; // 清理 sessionId
|
||||||
setWechatStatus(WECHAT_STATUS.EXPIRED);
|
setWechatStatus(WECHAT_STATUS.EXPIRED);
|
||||||
@@ -377,11 +352,6 @@ export default function WechatRegister() {
|
|||||||
setWechatSessionId(response.data.session_id);
|
setWechatSessionId(response.data.session_id);
|
||||||
setWechatStatus(WECHAT_STATUS.WAITING);
|
setWechatStatus(WECHAT_STATUS.WAITING);
|
||||||
|
|
||||||
logger.debug('WechatRegister', '获取二维码成功', {
|
|
||||||
sessionId: response.data.session_id,
|
|
||||||
authUrl: response.data.auth_url
|
|
||||||
});
|
|
||||||
|
|
||||||
// 启动轮询检查扫码状态
|
// 启动轮询检查扫码状态
|
||||||
startPolling();
|
startPolling();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
...getBaseProperties(),
|
...getBaseProperties(),
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '💬 WeChat Login Initiated', { source });
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
// ==================== 手机验证码流程 ====================
|
// ==================== 手机验证码流程 ====================
|
||||||
@@ -186,7 +185,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
session_id: sessionId?.substring(0, 8) + '...',
|
session_id: sessionId?.substring(0, 8) + '...',
|
||||||
has_auth_url: Boolean(authUrl),
|
has_auth_url: Boolean(authUrl),
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '🔲 WeChat QR Code Displayed', { sessionId: sessionId?.substring(0, 8) });
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,7 +196,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
...getBaseProperties(),
|
...getBaseProperties(),
|
||||||
session_id: sessionId?.substring(0, 8) + '...',
|
session_id: sessionId?.substring(0, 8) + '...',
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '📱 WeChat QR Code Scanned', { sessionId: sessionId?.substring(0, 8) });
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +209,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
session_id: sessionId?.substring(0, 8) + '...',
|
session_id: sessionId?.substring(0, 8) + '...',
|
||||||
time_elapsed: timeElapsed,
|
time_elapsed: timeElapsed,
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '⏰ WeChat QR Code Expired', { sessionId: sessionId?.substring(0, 8), timeElapsed });
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,7 +222,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
old_session_id: oldSessionId?.substring(0, 8) + '...',
|
old_session_id: oldSessionId?.substring(0, 8) + '...',
|
||||||
new_session_id: newSessionId?.substring(0, 8) + '...',
|
new_session_id: newSessionId?.substring(0, 8) + '...',
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '🔄 WeChat QR Code Refreshed');
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +237,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
old_status: oldStatus,
|
old_status: oldStatus,
|
||||||
new_status: newStatus,
|
new_status: newStatus,
|
||||||
});
|
});
|
||||||
logger.debug('useAuthEvents', '🔄 WeChat Status Changed', { oldStatus, newStatus });
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,7 +244,6 @@ export const useAuthEvents = ({ component = 'AuthFormContent', isMobile = false
|
|||||||
*/
|
*/
|
||||||
const trackWechatH5Redirect = useCallback(() => {
|
const trackWechatH5Redirect = useCallback(() => {
|
||||||
track(ACTIVATION_EVENTS.WECHAT_H5_REDIRECT, getBaseProperties());
|
track(ACTIVATION_EVENTS.WECHAT_H5_REDIRECT, getBaseProperties());
|
||||||
logger.debug('useAuthEvents', '🔗 WeChat H5 Redirect');
|
|
||||||
}, [track, getBaseProperties]);
|
}, [track, getBaseProperties]);
|
||||||
|
|
||||||
// ==================== 登录/注册结果 ====================
|
// ==================== 登录/注册结果 ====================
|
||||||
|
|||||||
Reference in New Issue
Block a user