Enable beta auto-deploy and Tianji consent-gated events (#35)
Unit Tests / test (pull_request) Successful in 14s

Flip workflows so master deploys beta and prod is workflow_dispatch only.
Load distinct Tianji website IDs from env; page views always on, custom events require consent.
This commit is contained in:
2026-07-27 07:27:22 -05:00
parent 28a805404a
commit befe3cdb4c
17 changed files with 639 additions and 30 deletions
+22 -6
View File
@@ -92,10 +92,12 @@ to be visible in the browser bundle.
| File | Used when | Backend (current) |
|------|-----------|-------------------|
| `.env.development` | `npm start` | `http://127.0.0.1:8001` |
| `.env.production` | `npm run build` / `build:prod` | `https://chatbackend.aimloperations.com` |
| `.env.beta` | `npm run build:beta` | `https://beta.chatbackend.aimloperations.com` |
| `.env.production` | `npm run build` / `build:prod` | `https://chatbackend.aimloperations.com` + prod Tianji ID |
| `.env.beta` | `npm run build:beta` | `https://beta.chatbackend.aimloperations.com` + beta Tianji ID |
| `.env.mobile` | `npm run build:mobile` | prod by default (override for beta shell) |
Each committed env sets `REACT_APP_DEPLOY_ENV` (`production` / `beta`) and `REACT_APP_TIANJI_WEBSITE_ID`.
Required keys (already set in the committed env files):
```env
@@ -184,20 +186,22 @@ npm run test:ci # one-shot (matches Gitea Unit Tests)
## CI / deployment
Gitea Actions workflows in `.gitea/workflows/`:
Gitea Actions workflows in `.gitea/workflows/` (same pattern as `dta_webapp`):
| Workflow | Trigger | Behavior |
|----------|---------|----------|
| `unit-tests.yml` | push/PR to `master` | `npm ci` + `npm run test:ci` in `llm-fe/` |
| `deploy-prod.yml` | after green **Unit Tests** on `master` **push** | `server-infra/scripts/deploy.sh --app chat_web_app --env prod --ref <sha>` |
| `deploy-beta.yml` | `workflow_dispatch` | tests, then deploy `--env beta` |
| `deploy-beta.yml` | **push** to `master` (after unit tests in-workflow) | `server-infra/scripts/deploy.sh --app chat_web_app --env beta --ref <sha>` |
| `deploy-prod.yml` | **manual** `workflow_dispatch` only | tests, then deploy `--env prod` |
Push/merge to `master` auto-deploys **beta** only. Prod requires the Gitea **Run workflow** button on Deploy Prod.
Deploy flow (on each webserver listed in `host_apps`):
1. Git checkout at the pinned ref under `/opt/apps/src/chat_web_app_<env>`
2. `npm ci` in `llm-fe/`
3. `npm run build:<env>` → writes the static tree under `/var/www/...`
4. **web-static** nginx serves that root on the host port (prod **8082**, beta **8083** if enabled)
4. **web-static** nginx serves that root on the host port (prod **8082**, beta **8083**)
Manual deploy from the control node:
@@ -209,9 +213,21 @@ Manual deploy from the control node:
NPM (not managed by Ansible) should balance public Hesychia domains to:
- `adama:8082` + `roslin:8082` + `ai-server-4080:8082` (prod)
- beta hosts on **8083** / `beta.chat.aimloperations.com` (see server-infra)
See [server-infra IMPLEMENTATION.md](https://git.aimloperations.com/ai_ml_operations/server-infra).
### Tianji analytics
| Build | Env file | Website ID |
|-------|----------|------------|
| prod | `.env.production` | `REACT_APP_TIANJI_WEBSITE_ID` (prod site) |
| beta | `.env.beta` | distinct beta site ID (set after creating website in Tianji) |
- Script: `https://tianji.aimloperations.com/tracker.js`
- **Page views** always load on prod/beta (no consent gate)
- **Custom events / identify** require analytics consent (`AnalyticsConsentBanner` + `trackEvent` / `identifyUser`)
## Related repos
- **Backend:** [chat_backend](https://git.aimloperations.com/ai_ml_operations/chat_backend) — Django API + WebSocket