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:
2026-06-12 16:21:21 +08:00
parent 4c9fd23b4f
commit 7bc21c1864
3 changed files with 59 additions and 1 deletions
+15
View File
@@ -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);
});
}