Add Umami analytics, subscription tiers, tool-call metering
- Analytics: <Analytics /> in root layout loads umami when NEXT_PUBLIC_UMAMI_* env are set - Subscription: free/pro tiers in Postgres, daily quotas (10msg/5tool free, 1000/500 pro) - Chat route: checkAndConsume(chat_message) gate before streamText, 429 when exhausted - Tool metering: getWeather wrapped with withLimit decorator that deducts tool_call quota - Pricing page at /pricing with upgrade button - /api/billing/checkout posts to EGBE payment gateway, /api/billing/webhook verifies HMAC and upgrades user on checkout.session.completed - UsageBadge in chat header polls /api/usage every 15s - Dropped now-unused entitlements.ts
This commit is contained in:
parent
3e21c2334c
commit
22a172e92d
23 changed files with 1374 additions and 86 deletions
22
.env.example
22
.env.example
|
|
@ -5,8 +5,28 @@ AUTH_SECRET=replace-me
|
|||
DATABASE_URL=postgres://user:pass@host:5432/db
|
||||
|
||||
# EGBE LiteLLM proxy — auto-injected by app-deploy.sh from the deploying instance
|
||||
EGBE_AI_API_URL=https://proxy.gcp.egbe.dev/v1
|
||||
EGBE_AI_API_URL=https://litellm.gcp.egbe.dev
|
||||
EGBE_AI_API_KEY=
|
||||
|
||||
# Public origin of this app — auto-injected by app-deploy.sh
|
||||
NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
||||
|
||||
# --- analytics (umami) ---
|
||||
# Auto-injected by app-deploy.sh after `analytics-site-create.sh <slug> <host> "<Name>"`
|
||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL=
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
|
||||
|
||||
# --- billing (payment gateway) ---
|
||||
# Auto-injected by app-deploy.sh from the deploying instance
|
||||
EGBE_PAYMENT_GATEWAY_URL=https://payments.gcp.egbe.dev
|
||||
EGBE_GATEWAYS_TOKEN=
|
||||
EGBE_PAYMENT_GATEWAY_WEBHOOK_SECRET=
|
||||
EGBE_PAYMENT_GATEWAY_WEBHOOK_HEADER=x-egbe-payment-signature
|
||||
|
||||
# Stripe price ID for the Pro plan — set per-product after creating the product via
|
||||
# the payment gateway API. Without it the upgrade button returns 501.
|
||||
PRO_STRIPE_PRICE_ID=
|
||||
|
||||
# App slug used in the webhook URL when creating checkout sessions. Must match the
|
||||
# slug you passed to app-deploy.sh.
|
||||
APP_SLUG=chatbot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue