chore(auth): add debug logging to guest login flow
Add console.log instrumentation across the guest login pipeline (auth-machine, authRepository, authApi) to trace request lifecycle and surface Zod parsing failures with detailed issue info. Useful for diagnosing lastMessageAt schema mismatches.
This commit is contained in:
@@ -123,16 +123,31 @@ export class AuthRepository implements IAuthRepository {
|
||||
* 成功后写 guest token + deviceId + userId。
|
||||
*/
|
||||
async guestLogin(deviceId: string): Promise<Result<GuestLoginResponse>> {
|
||||
console.log("[AuthRepository.guestLogin] API call START", {
|
||||
deviceIdLength: deviceId.length,
|
||||
deviceIdPrefix: deviceId.slice(0, 8),
|
||||
});
|
||||
return Result.wrap(async () => {
|
||||
const response = await this.api.guestLogin(
|
||||
GuestLoginRequest.from({ deviceId }),
|
||||
);
|
||||
console.log("[AuthRepository.guestLogin] API call SUCCESS (Zod parsed)", {
|
||||
hasToken: !!response.token,
|
||||
hasUser: !!response.user,
|
||||
userLastMessageAt: response.user?.lastMessageAt,
|
||||
});
|
||||
await this.storage.setGuestToken(response.token);
|
||||
await this.storage.setDeviceId(deviceId);
|
||||
if (response.userId) {
|
||||
await this.userStorage.setUserId(response.userId);
|
||||
}
|
||||
return response;
|
||||
}).catch((e) => {
|
||||
console.error("[AuthRepository.guestLogin] API call FAILED", {
|
||||
errorName: e?.name,
|
||||
errorMessage: e?.message,
|
||||
});
|
||||
return Result.err(e);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user