feat(telemetry): resolve profile and team names in session timelines
This commit is contained in:
@@ -77,6 +77,12 @@ export const SessionTimelineView = ({ sessionId }: { sessionId: string }) => {
|
|||||||
style={{ minWidth: 0, flex: 1 }}
|
style={{ minWidth: 0, flex: 1 }}
|
||||||
>
|
>
|
||||||
{entry.label}
|
{entry.label}
|
||||||
|
{entry.detail && entry.kind !== "error" && (
|
||||||
|
<Text component="span" size="sm" c="dimmed">
|
||||||
|
{" "}
|
||||||
|
· {entry.detail}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
{entry.kind === "server_fn" && entry.success === false && (
|
{entry.kind === "server_fn" && entry.success === false && (
|
||||||
<Text size="xs" c="red" style={{ flexShrink: 0 }}>
|
<Text size="xs" c="red" style={{ flexShrink: 0 }}>
|
||||||
|
|||||||
@@ -346,7 +346,43 @@ export const getSessionTimeline = createServerFn()
|
|||||||
|
|
||||||
entries.sort((a, b) => (a.ts < b.ts ? -1 : 1));
|
entries.sort((a, b) => (a.ts < b.ts ? -1 : 1));
|
||||||
|
|
||||||
const players = await playerInfoById(new Set(playerId ? [playerId] : []));
|
const profileIds = new Set<string>();
|
||||||
|
const teamIds = new Set<string>();
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.kind !== "page_view") continue;
|
||||||
|
const profileMatch = entry.label.match(/^\/profile\/([^/]+)$/);
|
||||||
|
if (profileMatch) profileIds.add(profileMatch[1]);
|
||||||
|
const teamMatch = entry.label.match(/^\/teams\/([^/]+)$/);
|
||||||
|
if (teamMatch) teamIds.add(teamMatch[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const players = await playerInfoById(
|
||||||
|
new Set([...(playerId ? [playerId] : []), ...profileIds])
|
||||||
|
);
|
||||||
|
|
||||||
|
const teamNames = new Map<string, string>();
|
||||||
|
if (teamIds.size > 0) {
|
||||||
|
try {
|
||||||
|
const teams = await pbAdmin.listTeamInfos();
|
||||||
|
for (const team of teams) {
|
||||||
|
if (teamIds.has(team.id)) teamNames.set(team.id, team.name);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.kind !== "page_view" || entry.detail) continue;
|
||||||
|
const profileMatch = entry.label.match(/^\/profile\/([^/]+)$/);
|
||||||
|
if (profileMatch) {
|
||||||
|
const player = players.get(profileMatch[1]);
|
||||||
|
if (player) {
|
||||||
|
entry.detail = [player.first_name, player.last_name].filter(Boolean).join(" ");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const teamMatch = entry.label.match(/^\/teams\/([^/]+)$/);
|
||||||
|
if (teamMatch) entry.detail = teamNames.get(teamMatch[1]);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
session: {
|
session: {
|
||||||
|
|||||||
Reference in New Issue
Block a user