mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-07-03 14:06:12 +02:00
chore: log RetroAchievements sync decisions and guard session-end errors
Add info logging at each RA sync gate (missing credentials, no game mapping, fetch result with new unlock count) and catch errors from the session-end sync so a failed RA fetch no longer rejects unhandled.
This commit is contained in:
@@ -171,9 +171,11 @@ const finalizeEmulatorSession = async (gameKey: string): Promise<void> => {
|
||||
});
|
||||
|
||||
if (game.shop === "launchbox") {
|
||||
void syncRetroAchievements({
|
||||
syncRetroAchievements({
|
||||
objectId: game.objectId,
|
||||
shop: game.shop,
|
||||
}).catch((error) => {
|
||||
logger.error("Failed to sync RetroAchievements on session end", error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,13 @@ export const syncRetroAchievements = async ({
|
||||
const webApiKey = userPreferences?.retroAchievementsWebApiKey;
|
||||
const username = userPreferences?.retroAchievementsUsername;
|
||||
|
||||
if (!webApiKey || !username) return null;
|
||||
if (!webApiKey || !username) {
|
||||
logger.info("RetroAchievements sync skipped: missing credentials", {
|
||||
hasWebApiKey: Boolean(webApiKey),
|
||||
hasUsername: Boolean(username),
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
const gameId = await resolveRetroAchievementsGameId(
|
||||
objectId,
|
||||
@@ -65,7 +71,13 @@ export const syncRetroAchievements = async ({
|
||||
retroAchievementsGameId
|
||||
);
|
||||
|
||||
if (!gameId) return null;
|
||||
if (!gameId) {
|
||||
logger.info("RetroAchievements sync skipped: no game mapping", {
|
||||
objectId,
|
||||
shop,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = await RetroAchievementsClient.getGameInfoAndUserProgress({
|
||||
username,
|
||||
@@ -124,6 +136,14 @@ export const syncRetroAchievements = async ({
|
||||
language: cachedAchievements?.language,
|
||||
});
|
||||
|
||||
logger.info("RetroAchievements progress fetched", {
|
||||
objectId,
|
||||
shop,
|
||||
gameId,
|
||||
remoteCount: remoteAchievements.length,
|
||||
newUnlockCount,
|
||||
});
|
||||
|
||||
if (newUnlockCount > 0) {
|
||||
HydraApi.post(
|
||||
`/profile/games/${shop}/${objectId}/retroachievements/sync`,
|
||||
|
||||
Reference in New Issue
Block a user