Add an `endpoint` column to `usage_history` (migration 103) so the proxy
records which API entry point a request came through — typically
`/v1/chat/completions`, `/v1/messages`, or `/v1/responses`. Every
`saveRequestUsage(...)` call site in `open-sse/handlers/chatCore.ts`
(success, stream, failure) and the codex-responses-ws route now plumbs
the endpoint through, and a new `getEndpointUsageRows(...)` analytics
query in `src/lib/db/usageAnalytics.ts` aggregates per
endpoint × provider × model with NULL → 'unknown' folding for backward
compatibility with rows from before the migration.
The aggregation reads directly from `usage_history` (matching the
`getAutoRoutingVariantBreakdown` pattern) so the existing unified-source
CTE — and the `daily_usage_summary` rollup it joins — stay untouched.
TDD: tests/unit/usage-endpoint-dimension.test.ts covers persistence
round-trip, NULL fallback, and the sinceIso filter (3/3 passing).
Co-authored-by: toanalien <toanalien@gmail.com>
Inspired-by: https://github.com/decolua/9router/pull/152