Guide
proxy-analytics shows you which fields of your API responses your app actually uses.
You add a small SDK to your app. As your app runs, the SDK notices which fields of each JSON response your code reads, and sends counts to this dashboard: field names and how often they were read, never the values. The dashboard turns those counts into a report per endpoint. Every field is marked as read, only copied around, or never read at all.
The result is a list of data your API sends that nobody uses: fields you could stop sending, or columns you could stop selecting.
How it works
- Your app calls your API as usual. Nothing about the request changes: no extra headers, no changed bodies, and responses outside the APIs you list are left alone.
- The SDK watches what your code reads. It wraps each JSON response in lightweight trackers. When your code reads
product.price, the SDK records thatpricewas read in that response. - It also notes which fields existed. In the background it records the shape of each response (which fields were present), so it can tell you about fields that were never read.
- Every 10 seconds it sends a batch of counts to the dashboard, and again when the page is hidden or closed. On a server, you can also send immediately (see Server-side tracking).
- The dashboard adds the batches up per day and shows them on the Usage tab.
Only field paths (like items[*].price.amount) and whole-number counts leave your app.
Getting started
1. Add an API
On Your APIs, enter a name and click Create. An "API" here is one thing you want a report for. Usually that's one backend, or one app talking to it.
A few tips:
- Separate environments. Make one API for local testing ("Shop API (local)") and one for production. Reports are grouped by endpoint path, so test traffic and real traffic would otherwise mix.
- Separate frontends, if you want separate answers. If a web app and an admin app call the same backend and you want to know what each uses, give each its own API.
A new API opens on its Usage tab with a setup checklist. The checklist ticks itself off as you go and turns into the report as soon as the first data arrives.
Switch between APIs with the name and ▾ menu at the top left. The tabs (Usage · Keys · Install · Settings) stay where they are when you switch.
2. Create a key
On the Keys tab, click New key, choose a type, give it a name you'll recognise later (e.g. "Next.js server, production"), and click Create key.
| Browser key | Server key | |
|---|---|---|
| Looks like | pa_pub_… |
pa_sec_… |
| Use it in | frontend code that runs in the browser | server code: Next.js, Node, serverless functions |
| Secret? | No. It ships in your frontend, so anyone can see it. | Yes. Keep it in environment variables. |
| Protection | only accepted from your allowed origins | refused if it's ever sent from a browser |
| Shown again later? | Yes: copy it or hover over it in the keys table | No, only once, right after you create it |
Both kinds of key can only send counts. Neither can read your reports or change anything, so a leaked key can't expose your data. The worst it can do is add noise to your report.
Server keys are shown once. The dashboard stores only a fingerprint (a hash) of each server key, so it can't show the key to you again. The dialog stays open until you've copied it or ticked "I've saved this key somewhere safe". If you lose one, create a new key, put it in your environment, then Revoke the old one.
The keys table shows when each key was last used. It updates at most once a minute while the key is sending. "Never" after you've used your app means the batches aren't arriving; see Troubleshooting.
Revoking a key is immediate and permanent: anything still sending with it is refused. Data already collected with it stays.
3. Allow your origins
Only needed for browser keys.
On the Settings tab, list where your app's pages run, one per line:
https://shop.example.com
https://*.example.com
http://localhost:5173
- Use the exact scheme, host and port your pages load from:
http://localhost:5173andhttp://localhost:3000are different origins. https://*.example.comcovers every subdomain (www.example.com,staging.example.com), but notexample.comitself. List that separately if you need it.- List the address of your app, not this dashboard and not your API.
- Avoid wildcards on shared hosting domains such as
https://*.vercel.apporhttps://*.netlify.app: anyone's site there would match. Use your own domain, or list the exact address.
Batches from a browser key on a page that isn't listed are refused, so someone who copies your key from your site can't send data from theirs.
4. Install the SDK
npm install proxy-analytics # or pnpm add / yarn add / bun add
The Install tab has ready-to-copy snippets with your newest browser key and this dashboard's address already filled in:
- Browser (REST API): for single-page apps and any frontend that calls a JSON API with
fetch, axios, ky, TanStack Query, SWR and similar. - Server (Next.js + Supabase): for server components, server actions and route handlers that query Supabase.
- Server (Node): for any Node.js server or backend-for-frontend.
Two settings matter most:
apis: the API addresses to track, e.g.'https://api.example.com'or'/api'. Only responses from these are tracked; everything else passes through untouched.sampleRate(browser) orresponseSampleRate(server): the fraction of traffic to track.0.25tracks a quarter. Untracked page loads skip tracking entirely and cost nothing. Start higher while testing, and lower it for busy production apps.
Install first. Call install() before anything else in your entry file, so it's in place before your app's first request.
5. Use your app
Load a few pages or call your server. The first batch arrives within about 10 seconds. The Usage tab updates on its own and switches from the checklist to the report.
Reading the report
The top bar
- responses: how many API responses were tracked in the selected range, across all endpoints.
- sessions: how many tracked page loads sent data. On a server, each running server process counts as one.
- endpoints: how many different endpoints were seen.
- Today · 7 days · 30 days · 90 days: the date range. Days are UTC days, so "Today" starts at midnight UTC.
These are counts of what was tracked, not of all your traffic. With sampleRate: 0.25 you'll see roughly a quarter of your real volume. The proportions (what's read, what isn't) are what matter.
The endpoint list
On the left is every endpoint, busiest first, e.g. GET /api/products/:id.
- Requests are grouped by method and path. IDs in the path (numbers, UUIDs, long hex strings) are replaced with
:id, and query strings are dropped, soGET /api/products/123?ref=xandGET /api/products/456count as one endpoint. - Supabase queries tracked on a server are grouped per query instead, e.g.
GET cases?select=*. That gives one report per select list. - Under each endpoint: how many responses were tracked, and how many of its fields were never read, e.g. "12/40 fields unused".
Click an endpoint to see its fields.
The endpoint summary
- responses tracked: responses from this endpoint that the SDK tracked.
- responses inventoried: of those, how many it recorded the full shape of. Usually the same number; it can be lower if inventory is sampled or a page closed before it finished.
- leaf fields seen: fields that hold a value rather than more fields.
price.amountis a leaf;priceisn't. - never read: leaf fields that nothing in your app touched, not even a copy.
- of fields unused: the share of leaf fields never read.
Field names
Fields are written as paths into the response:
| Path | Means |
|---|---|
price.amount |
the amount inside price |
items[*].name |
the name of any item in the items list. All items count as one field. |
byId.{*}.name |
the name inside any entry of an object keyed by IDs, e.g. { "8f3a…": { "name": … } } |
["a.b"] |
a field whose name itself contains a dot or other special characters |
A response that is a list at the top level starts with [*], e.g. [*].title.
Read, bulk only and never read
Every field gets one of three labels:
- read: your code read this field directly at least once, e.g.
product.priceor'price' in product. This is real use. - bulk only: the field was only touched by code that goes through every field of an object at once. That includes spreading (
{ ...product }),Object.assign,JSON.stringify, deep-equality checks, copies made by state libraries and query caches, and sending data from the server to the browser. Nothing looked at this field specifically, but the data was passed along. - never read: nothing touched it at all.
"Bulk only" doesn't automatically mean "unused". A field that's copied into a store and later sent back to the API in an update is still needed. But if a field is bulk only everywhere, it's often just along for the ride. Check where the object goes before you drop it.
On a server, objects passed to client components are converted to send to the browser, which counts as a bulk walk of every field in them. So bulk only on a server usually means "shipped to the browser". That's a finding in itself: those fields reach the client. Pass narrower objects to client components to see exactly what's needed.
The field table
| Column | What it shows |
|---|---|
| Field | The field's path. With no filter applied it's shown as a tree: click ▸ / ▾ to collapse or expand. A collapsed field shows how many fields are nested under it, and how many of those are never read. |
| Present in | In how many inventoried responses the field existed at all, e.g. 40 / 50 (80%). Optional fields show less than 100%. |
| Read in | In how many of the responses that contained the field your code read it directly, e.g. 30 / 48 (63%). "+5 bulk" means in 5 more responses it was only touched by a bulk walk. In the bar, green is direct reads and orange is bulk. |
| Direct | Responses with a direct read of this field. |
| Bulk | Responses where the field was touched by a bulk walk (whether or not it was also read directly). |
| (label) | read, bulk only, or never read. |
Counts are per response, not per read. If a page renders 50 products and shows each price, that's one response in which items[*].price was read, not 50.
"Read in" is measured against the responses that actually contained the field. An optional field that appears in 10% of responses and is read every time it appears shows 100%, not 10%.
Filters and search
- All: every field, as a tree.
- Never read: fields nothing touched. Start here to find waste.
- Bulk only: fields that were only copied or serialized. Worth checking where those objects go.
- Read: fields your code read directly.
- Read + Bulk: everything that was touched in any way (the opposite of Never read).
Type in Filter fields… to search by path. While a filter or search is active, fields are listed with their full paths instead of as a tree. Expand all and Collapse all work in the tree view, and the dashboard remembers which fields you collapsed, per endpoint, in your browser.
Narrower query (Supabase)
For Supabase queries tracked on a server, the report can suggest a smaller select list, e.g.:
Narrower query:
.select('id,title,status')
It keeps every column your code touched, including bulk-only ones, and drops the columns never read in the selected range. It isn't shown when nothing could be dropped, or for queries that embed other tables (select('*, client(*)')).
An example
Say GET /api/products/:id shows this row:
| Field | Present in | Read in | Direct | Bulk | |
|---|---|---|---|---|---|
vendor.internalCode |
200 / 200 (100%) | 0 / 200 (0%) · +200 bulk | 0 | 200 | bulk only |
Every product response includes vendor.internalCode. Your code never reads it directly, but every response passed through a bulk walk, perhaps because the product is copied into a store or sent to a client component. If nothing downstream reads it either, it's a candidate to remove. If the same row said never read, nothing touched it at all, which makes it an even stronger candidate.
Before you remove a field
Treat never read as a strong lead, not a verdict:
- Other consumers. The report only covers the apps you installed the SDK in. A mobile app, a partner integration or another service might read the field.
- Rare screens. A field used only on an admin page or at year-end won't show up until someone visits that page. Look at a long enough range (30 or 90 days) with enough sessions.
- Sampling. With a low sample rate, rarely used fields take longer to show up. The response and session counts tell you how much evidence you're looking at.
- Copied values. If your code copies a single value out of a response (
const name = product.name) and usesnamelater, the copy counts as a read, but later uses ofnamearen't tracked separately. That's rarely a problem in practice.
A good habit: remove a field from what the API sends (or from your select) behind a flag or in a staging environment first, and watch for errors.
Server-side tracking
The SDK also runs on servers, where it tracks what your server code reads from the APIs and databases it calls. This is where Next.js apps often waste the most: select('*') from the database when the page uses a handful of columns.
- Use a server key, kept in an environment variable (
PROXY_ANALYTICS_KEY). - Use
responseSampleRaterather thansampleRate. A server is one long-running process, so sampling decides per response, not per session. - Serverless hosts (Vercel functions, AWS Lambda) can freeze right after responding, before the 10-second send. Call
flush()where the platform keeps the function alive: in Next.js,after(flush)in pages, server actions and route handlers. The Next.js snippet on the Install tab includes this. - Long-running servers send on their own every 10 seconds.
Privacy and security
- Values never leave your app. Batches contain field paths and whole-number counts only. No names, emails, prices, IDs or response bodies.
- The SDK doesn't change your requests. No extra headers and no changed bodies. Responses from addresses you didn't list in
apisaren't touched at all. - Keys can only send data. They can't read reports. Browser keys only work from your allowed origins, and server keys are refused if they're ever used from a browser.
- Server keys are stored as hashes, so nobody, including us, can read them back.
- Your reports are private to your account. Other users can't see your APIs, keys or data. The dashboard's operator can view an account's APIs and reports, read-only, to help with support. They can't change anything, and like everyone else they can't see server keys.
Troubleshooting
The checklist never goes away / no data arrives.
Open your browser's developer tools on your app's page (or your server's logs) and look for requests to /api/collect.
| What you see | What it means | What to do |
|---|---|---|
No /api/collect requests at all |
The SDK isn't tracking anything | Check apis matches the address your app calls, that install() runs before your first request, and that sampleRate isn't too low for a quick test (use 1 while testing). |
| 401 | Unknown key | Check for typos. Keys from another copy of this dashboard (e.g. a local one) won't work here. The key may also have been revoked. |
| 403 from a browser | This page's origin isn't allowed, or a server key was used in the browser | Add the exact origin under Settings, or use a browser key in frontend code. |
| 403 from a server | A browser key was used on the server, or the key's origin check failed | Use a server key for server code. |
| 429 | Too many batches from one key | The limit is generous (hundreds per minute per key). Check for a loop, or lower the sample rate. |
| 413 | A batch was too large | Very unusual. It means an enormous number of distinct fields. |
| Requests fail with a network error | The endpoint address is wrong or unreachable |
Copy the endpoint again from the Install tab. |
A field I definitely use shows as never read. Check that the read happens on the response object, not on a copy made in an unusual way. Code that rebuilds objects from raw property descriptors bypasses tracking. Also check the date range: today's data only covers today, in UTC.
Everything on my server shows as bulk only. That's expected for data passed straight to client components: it's serialized for the browser. See Read, bulk only and never read.
"Last used" stays "never". No batch with that key has been accepted. Use the table above to find out why.
No data for "Today", but I used the app. Days are UTC. Late in the evening in the Americas, "Today" may have just started. Try 7 days.