A small observability dashboard that monitors wc_ajax=add_to_cart request latency using Cloudflare's GraphQL Analytics API. Shows request counts and latency (median, p95) over the last 24h, refreshing automatically every 5 minutes.
project/
api/ PHP endpoint that proxies Cloudflare's GraphQL API
app/ Vite + React + TypeScript frontend
.env Local config
cd app
npm install
npm run dev # starts Vite dev server with proxy to the PHP API
npm run test # runs vitest
npm run build # production build, outputs to app/dist/
npm run lintcd api
php -S localhost:9000The Vite dev server proxies /api/* requests to localhost:9000, so run both servers side by side during development.
The PHP endpoint reads config from a .env file located one directory above the webroot.
| Key | Description |
|---|---|
ENV |
development or production |
CF_TOKEN |
Cloudflare API token with Analytics read access |
CF_ZONE_TAG |
Cloudflare zone ID to query |
CF_ENDPOINT |
Cloudflare GraphQL endpoint URL |
cd app && npm run build- Upload
app/dist/andapi/cf.phpcontents to the target subfolder on the server - Place the
.envfile one directory above webroot on the server
