feat: add admin stats page with token usage

This commit is contained in:
Alexej Wolff
2026-02-11 01:00:02 +01:00
parent 6616c2e9a7
commit c404b1e17c
6 changed files with 455 additions and 0 deletions
+34
View File
@@ -300,3 +300,37 @@ export async function deletePlayerCharacter(id: string): Promise<boolean> {
return false;
}
}
// ============ ADMIN STATS ============
interface StoryStats {
id: string;
title: string;
messageCount: number;
tokens: number;
lastPlayed: string | null;
}
interface AdminStats {
totalStories: number;
totalSessions: number;
totalTokens: number;
stories: StoryStats[];
}
export async function getAdminStats(): Promise<AdminStats | null> {
try {
const response = await fetch(`${API_URL}/api/admin/stats`, {
credentials: "include",
});
if (!response.ok) {
return null;
}
return await response.json();
} catch (error) {
console.error("Failed to get admin stats:", error);
return null;
}
}