Skip to content

chore(release): staging to production - 2026.06.03 - #1094

Merged
ct3685 merged 1 commit into
productionfrom
staging
Jun 3, 2026
Merged

chore(release): staging to production - 2026.06.03#1094
ct3685 merged 1 commit into
productionfrom
staging

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

🚀 Release: Staging to Production

Release Date: 2026-06-03

Changes in this release


This PR is automatically created/updated when commits are pushed to staging.
Merging this PR will trigger the release workflow to create a new GitHub release.

## Summary

Fixes two bugs on the API Keys page (`/sidekick-studio/apikey`) and adds
real per-key usage tracking.

- **"Updated" always showed today** — the UI read `apiKey.createdAt`,
which the server never sent, so `moment(undefined)` rendered as the
current date.
- **"Usage" always 0** — that column was really `chatFlows.length`
(connected chatflows); there was no API-call counter at all.

### Changes
**Server**
- `ApiKey` entity + `IApiKey`: add `createdAt` (`@CreateDateColumn`) and
`usageCount` (int, default 0).
- New Postgres migration `1770000000004-AddApiKeyUsageTracking` — adds
both columns and backfills `createdAt` from `updatedDate` for existing
rows.
- New `apikeyService.recordApiKeyUsage(id)` — atomic `usageCount + 1`
and `lastUsedAt = now()`.
- Wired fire-and-forget into the API-key auth chokepoint
(`handleApiKeyAuth` in `index.ts`) so every authenticated request with a
key is counted without adding latency.
- `importKeys` now persists the imported `createdAt` (previously
validated then discarded).

**UI** (`packages/ui/src/views/apikey/index.jsx`)
- Replaced the conflated columns with: **Connected | API Calls | Last
Used | Created** (dropped the buggy "Updated"). Updated skeleton rows
and the collapsible `colSpan`.

### Notes
- Migration is **Postgres-only** (the deployment DB). Can add
mysql/mariadb/sqlite parity if desired.
- Dropped "Updated" in favor of "Created"; easy to restore both if
preferred.

## Test plan

Verified live against the dev stack + real Postgres:
- [x] Migration applies; `apikey` gains `createdAt` (not null) and
`usageCount` (default 0); existing key backfilled to its real created
date.
- [x] **API Calls**: 3 authenticated requests → `usageCount` 0→3
(further list calls increment as expected).
- [x] **Last Used**: `lastUsedAt` null → updates on each use.
- [x] **Created**: shows real creation date (May 4), not today.
- [x] **Connected**: linking a chatflow via `apikeyid` shows count 1
with flow details (test row cleaned up).
- [x] `GET /api/v1/apikey` payload includes `createdAt`, `usageCount`,
`lastUsedAt`.
- [x] UI renders all columns correctly (Connected, API Calls, Last Used
= June 3rd 2026, Created = May 4th 2026).
@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
answerai-docs Building Building Preview Jun 3, 2026 9:46pm
the-answerai Building Building Preview Jun 3, 2026 9:46pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants