proxy-analytics field usage
Guide

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

  1. 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.
  2. The SDK watches what your code reads. It wraps each JSON response in lightweight trackers. When your code reads product.price, the SDK records that price was read in that response.
  3. 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.
  4. 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).
  5. 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:

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

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:

Two settings matter most:

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

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.

Click an endpoint to see its fields.

The endpoint summary

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:

"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%.

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:

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.

Privacy and security

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.