Skip to content
Open
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
13 changes: 9 additions & 4 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

- Search by name/email
- Filter by billing group
- Time range: 24h / 3d / 7d / 14d / 30d
- Time range: 24h / 3d / 7d / 14d / 30d / Cycle (default, from the billing cycle start). Spend, ranks, $/req and the charts all follow the selected range, over as many billing cycles as it spans.

### Stat Cards

Expand All @@ -21,10 +21,10 @@

### Charts

- **Daily Spend Trend** — area chart with avg line, provisional zone (last 2d), spike detection
- **Daily Spend Trend** — area chart with avg line, provisional zone (last 2d), cycle change marker, spike detection
- **Model Cost Comparison** — table with $/request, relative multiplier (1x–8x+), color-coded
- **Top Spenders** — horizontal bar chart, top 8
- **Daily Spend by User** — stacked bar, top 6 + Others, clickable legend
- **Daily Spend by User** — stacked bar, top 6 + Others, clickable legend, cycle change marker

### Members Table

Expand Down Expand Up @@ -57,10 +57,11 @@

- Name, email, role, billing group link
- Profile badges (same as dashboard)
- Time range: 24h / 3d / 7d / 14d / 30d / Cycle (default)

### KPI Cards

- **Cycle Spend** — total $ in billing cycle, $/day
- **Spend** — total $ in time range, $/day
- **$/Req** — cost per agent request
- **Agent Reqs** — total requests in time range
- **Diffs Accepted** — % of agent diffs accepted (accepts/applies), raw counts
Expand All @@ -86,6 +87,10 @@

**Team analytics — adoption, efficiency, trends.**

### Controls

- Time range: 24h / 3d / 7d / 14d / 30d / Cycle (default), all sections except Plan Exhaustion and Client Versions

### Stat Cards

- Avg DAU, Commands total, Agent lines accepted, Tab lines accepted, MCP tools count
Expand Down
6 changes: 4 additions & 2 deletions src/app/api/analytics/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getUsersByClientVersion,
getPlanExhaustionStats,
getModelEfficiency,
getCycleWindowDays,
getGroupsWithMembers,
getRepoAIAttribution,
} from "@/lib/data";
Expand Down Expand Up @@ -39,7 +40,8 @@ function resolveGroupEmails(group: string): string[] | undefined {

export function GET(request: Request) {
const { searchParams } = new URL(request.url);
const days = parseInt(searchParams.get("days") ?? "30", 10);
const param = searchParams.get("days") ?? "30";
const days = param === "cycle" ? getCycleWindowDays() : parseInt(param, 10) || 30;
const group = searchParams.get("group") ?? "all";
const emails = resolveGroupEmails(group);

Expand All @@ -56,7 +58,7 @@ export function GET(request: Request) {
clientVersions: getAnalyticsClientVersionsSummary(),
versionUsers: getUsersByClientVersion(),
planExhaustion: getPlanExhaustionStats(emails),
modelEfficiency: getModelEfficiency(emails),
modelEfficiency: getModelEfficiency(emails, days),
repoAttribution: getRepoAIAttribution(days, emails),
});
} catch {
Expand Down
5 changes: 3 additions & 2 deletions src/app/api/stats/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export const dynamic = "force-dynamic";

export function GET(request: Request) {
const url = new URL(request.url);
const days = parseInt(url.searchParams.get("days") ?? "30", 10);
const param = url.searchParams.get("days") ?? "30";
const range = param === "cycle" ? "cycle" : parseInt(param, 10) || 30;

const dashboard = getFullDashboard(days);
const dashboard = getFullDashboard(range);
return NextResponse.json(dashboard);
}
5 changes: 3 additions & 2 deletions src/app/api/users/[email]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export function GET(request: Request, { params }: { params: Promise<{ email: str
return params.then((p) => {
const email = decodeURIComponent(p.email);
const url = new URL(request.url);
const days = parseInt(url.searchParams.get("days") ?? "30", 10);
const param = url.searchParams.get("days") ?? "30";
const range = param === "cycle" ? "cycle" : parseInt(param, 10) || 30;

const stats = getUserStats(email, days);
const stats = getUserStats(email, range);
return NextResponse.json(stats);
});
}
Loading
Loading