Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/junior-dashboard/src/api/people/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { readPeopleList } from "@sentry/junior/api/people/list";

/** Serve the dashboard people list endpoint from the SQL-backed people API. */
export async function peopleListResponse(): Promise<Response> {
try {
return Response.json(await readPeopleList());
} catch (error) {
console.error("Failed to load people list", error);
return Response.json(
{ error: "Failed to load people list" },
{ status: 500 },
);
}
}
18 changes: 18 additions & 0 deletions packages/junior-dashboard/src/api/people/profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { readPeopleProfile } from "@sentry/junior/api/people/profile";

/** Serve the dashboard person profile endpoint from the SQL-backed people API. */
export async function peopleProfileResponse(email: string): Promise<Response> {
if (!email.trim()) {
return Response.json({ error: "Email is required" }, { status: 400 });
}

try {
return Response.json(await readPeopleProfile(email));
} catch (error) {
console.error("Failed to load person profile", error);
return Response.json(
{ error: "Failed to load person profile" },
{ status: 500 },
);
}
}
90 changes: 4 additions & 86 deletions packages/junior-dashboard/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import type {
ConversationStatsReport,
PluginOperationalReportFeed,
JuniorReporting,
RequesterDirectoryReport,
RequesterProfileReport,
} from "@sentry/junior/reporting";
import { createJuniorReporting } from "@sentry/junior/reporting";
import { initSentry } from "@sentry/junior/instrumentation";
Expand All @@ -25,6 +23,8 @@ import {
} from "./auth";
import { dashboardRainbowProgressClass } from "./dashboardLoader";
import { createMockConversationReporting } from "./mock-conversations";
import { peopleListResponse } from "./api/people/list";
import { peopleProfileResponse } from "./api/people/profile";

const DEFAULT_BASE_PATH = "/";
const DEFAULT_AUTH_PATH = "/api/auth";
Expand Down Expand Up @@ -235,48 +235,6 @@ function emptyConversationStatsReport(): ConversationStatsReport {
};
}

function emptyRequesterDirectoryReport(): RequesterDirectoryReport {
return {
generatedAt: new Date().toISOString(),
people: [],
sampleLimit: 0,
sampleSize: 0,
source: "conversation_index",
truncated: false,
};
}

function emptyRequesterProfileReport(email: string): RequesterProfileReport {
const nowMs = Date.now();
const end = new Date(nowMs);
end.setUTCHours(0, 0, 0, 0);
const start = new Date(end);
start.setUTCDate(start.getUTCDate() - 365);
return {
activityDays: [],
generatedAt: new Date(nowMs).toISOString(),
locations: [],
recentConversations: [],
requester: { email },
sampleLimit: 0,
sampleSize: 0,
source: "conversation_index",
surfaces: [],
totals: {
active: 0,
activeDays: 0,
conversations: 0,
durationMs: 0,
failed: 0,
hung: 0,
runs: 0,
},
truncated: false,
windowEnd: end.toISOString(),
windowStart: start.toISOString(),
};
}

async function readConversationStats(
reporting: JuniorReporting,
): Promise<ConversationStatsReport> {
Expand All @@ -295,25 +253,6 @@ async function readPluginReports(
return await reporting.getPluginOperationalReports();
}

async function readRequesterDirectory(
reporting: JuniorReporting,
): Promise<RequesterDirectoryReport> {
if (!reporting.listRequesters) {
return emptyRequesterDirectoryReport();
}
return await reporting.listRequesters();
}

async function readRequesterProfile(
reporting: JuniorReporting,
email: string,
): Promise<RequesterProfileReport> {
if (!reporting.getRequesterProfile) {
return emptyRequesterProfileReport(email);
}
return await reporting.getRequesterProfile(email);
}

function callbackUrl(request: Request, basePath: string): string {
const requestUrl = new URL(request.url);
const returnPath = requestedReturnPath(requestUrl, basePath);
Expand Down Expand Up @@ -712,30 +651,9 @@ export function createDashboardApp(
);
}
});
app.get("/api/people", async () => {
try {
return Response.json(await readRequesterDirectory(reporting));
} catch {
return Response.json(
{ error: "People failed to load." },
{ status: 500 },
);
}
});
app.get("/api/people", () => peopleListResponse());
app.get("/api/people/:email", async (c) => {
try {
return Response.json(
await readRequesterProfile(
reporting,
decodeURIComponent(c.req.param("email")),
),
);
} catch {
return Response.json(
{ error: "Profile failed to load." },
{ status: 500 },
);
}
return peopleProfileResponse(decodeURIComponent(c.req.param("email")));
Comment thread
dcramer marked this conversation as resolved.
});
app.get("/api/plugin-reports", async () => {
try {
Expand Down
18 changes: 11 additions & 7 deletions packages/junior-dashboard/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import type {
ConversationSubagentTranscriptReport as ReportingConversationSubagentTranscriptReport,
PluginOperationalReportFeed,
PluginOperationalReport,
RequesterActivityDayReport,
RequesterDirectoryReport,
RequesterIdentity as ReportingRequesterIdentity,
RequesterProfileReport,
RequesterSummaryReport,
RequesterTotalsReport,
ConversationFeed as ReportingConversationFeed,
ConversationSummaryReport,
ConversationRunReport,
Expand All @@ -21,6 +15,16 @@ import type {
RuntimeInfoReport,
SkillReport,
} from "@sentry/junior/reporting";
import type {
RequesterDirectoryReport,
RequesterIdentity as ApiRequesterIdentity,
RequesterSummaryReport,
RequesterTotalsReport,
} from "@sentry/junior/api/people/list";
import type {
RequesterActivityDayReport,
RequesterProfileReport,
} from "@sentry/junior/api/people/profile";

export type Health = HealthReport;

Expand All @@ -41,7 +45,7 @@ export type ConversationSubagentTranscript =

export type ConversationStatsItem = ReportingConversationStatsItem;

export type RequesterIdentity = ReportingRequesterIdentity;
export type RequesterIdentity = ApiRequesterIdentity;

export type RequesterActivityDay = RequesterActivityDayReport;

Expand Down
Loading
Loading