Add generation_usage table and per-request logging middleware for billing metering #1094

Open
opened 2026-04-12 14:12:50 -04:00 by pook · 0 comments
Owner

Create a database migration for a generation_usage table with columns: id, user_id, subscription_id, document_type, character_count, created_at. Add middleware that runs AFTER /api/generate completes successfully and inserts a row into this table. This enables billing metering and usage-based pricing.

Acceptance criteria:

  • Migration creates generation_usage table with proper foreign keys to users and stripe_subscriptions
  • Middleware captures user_id, subscription_id, document_type from request body, and character_count of output
  • Only logs on successful (2xx) responses
  • Does not block or slow down the response if logging fails

Generated by CEO Planner (priority: 3)

Create a database migration for a `generation_usage` table with columns: id, user_id, subscription_id, document_type, character_count, created_at. Add middleware that runs AFTER /api/generate completes successfully and inserts a row into this table. This enables billing metering and usage-based pricing. Acceptance criteria: - Migration creates generation_usage table with proper foreign keys to users and stripe_subscriptions - Middleware captures user_id, subscription_id, document_type from request body, and character_count of output - Only logs on successful (2xx) responses - Does not block or slow down the response if logging fails --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1094
No description provided.