Skip to content

feat: per-slug rate limiting, analytics tracking, and failover support#3

Open
kousthubha-sky wants to merge 4 commits intosunithvs:mainfrom
kousthubha-sky:main
Open

feat: per-slug rate limiting, analytics tracking, and failover support#3
kousthubha-sky wants to merge 4 commits intosunithvs:mainfrom
kousthubha-sky:main

Conversation

@kousthubha-sky
Copy link

Changes

Proxy worker

  • 3-layer KV rate limiting (global / per-IP / per-user) with burst allowance
  • Expanded Analytics Engine tracking: latency ms, service tag, upstream used
  • Primary → backup Supabase URL failover with auto-recovery

API

  • Analytics endpoints: /analytics, /analytics/latency, /analytics/endpoints, /analytics/errors
  • Failover endpoints: /failover-status, /failover-reset

Database

  • Migration 0002: rate_limit_burst_size, track_per_ip, track_per_user columns
  • Migration 0003: backup_supabase_url, enable_failover, failover_threshold_ms columns
  • Zero data loss — all new columns have safe defaults

Dashboard

  • New analytics page: p50/p95/p99 latency, service breakdown, hourly error chart
  • Settings page: burst size, per-IP/user toggles, failover config
  • App detail page: Analytics button, failover status pill

New env vars needed (API worker)

  • CF_ACCOUNT_ID — Cloudflare account ID
  • CF_API_TOKEN — API token with Analytics Engine read permission

Migrations

Run automatically on next deploy via the existing deploy script.

- Implement failover status and reset endpoints in the API.
- Add analytics endpoints for latency, endpoint breakdown, and error tracking.
- Update AppRecord interface to include failover and rate limiting configurations.
- Enhance dashboard to display failover status and analytics data.
- Introduce new SQL migrations for failover and rate limiting configurations in the database.
- Create analytics library for querying Cloudflare's analytics engine.
- Implement rate limiting logic in the proxy with support for burst size and tracking options.
- Add new Svelte components for displaying analytics data in the dashboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants