Repository navigation
feat(wake): order analytics — totals, PII-free projection, dashboard, rate gate - #600
Merged
Merged
Conversation
… rate gate WAKE_LIST_ORDERS now returns Wake's x-total-count (total, hasMore), reads a bare day as the whole day (a date-only dataFinal used to end the range at midnight and return nothing), and takes direcaoOrdenacao, listaPedidosIds, DataStatus and camposAdicionais. fields: "analytics" returns each order without the buyer, documents, street address, card, Pix QR or free-text notes. New read tools: WAKE_DASHBOARD (/dashboard/* aggregates), WAKE_LIST_PAYMENT_METHODS, WAKE_LIST_ORDER_ORIGINS, WAKE_LIST_DISTRIBUTION_CENTERS and WAKE_LIST_PHYSICAL_STORES. Every Admin call goes through a per-token gate: at most WAKE_ADMIN_MAX_PER_MINUTE (default 100) per minute, and after a 429 the token is refused locally until Retry-After, with a [wake-rate-limited] error and no retry. Wake blocks a token for an hour when it keeps calling past its limit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
yuriassuncx
approved these changes
Nov 26, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Analytics apps reading a Wake store's orders through this MCP (first one: insights-mcp's sales radar) hit four problems:
WAKE_LIST_ORDERSdropped Wake'sx-total-countheader. A caller couldn't size its paging or tell how many orders a day had.2026-11-25as midnight. A date-onlydataFinalended the range where it started, with no error.What
WAKE_LIST_ORDERS(backwards compatible:itemsandcountare unchanged,fieldsdefaults tofull)total(fromx-total-count),page,pageSizeandhasMore.00:00:00to23:59:59.Tis accepted as the separator.direcaoOrdenacao,listaPedidosIds(up to 50 ids in one call, instead ofWAKE_GET_ORDERin a loop),DataStatusinenumTipoFiltroData, andcamposAdicionais. Array params are sent as repeated keys.fields: "analytics"is a whitelist projection (lib/order-analytics.ts).New read tools
WAKE_DASHBOARD/dashboard/{receita,transacoes,ticketMedio,faturamento,graficofaturamento,graficoformapagamento,produtos,novoscompradores,carrinhoabandonado,produtoestoque}WAKE_LIST_PAYMENT_METHODS/formasPagamentoWAKE_LIST_ORDER_ORIGINS/origensPedidoWAKE_LIST_DISTRIBUTION_CENTERS/centrosdistribuicaoWAKE_LIST_PHYSICAL_STORES/lojasFisicas(paged, withtotal)Rate gate (
lib/rate-gate.ts, applied to every Admin call)WAKE_ADMIN_MAX_PER_MINUTEcalls per minute (default 100) per process. A call waits up to 15 s for a free slot.Retry-Afterhas passed, without reaching Wake.[wake-rate-limited] … retry-after=<s>, so callers can back off.Also: the README documents dates (store local time, no offset), the page-199 ceiling and the rate limit.
app.json,registry.jsonand the version (1.1.0) are updated.Verified
bun test(wake): 22 pass. They cover the gate (pacing, refusal, 429 block,Retry-Afterparsing), the client (x-total-count, the 429 stop, array query strings), the date range andhasMore, and the analytics projection. The projection tests use a synthetic order that carries every personal field, and assert that none of them survive.scripts/check.ts wake,oxfmt --check,oxlintandcheck:registryare clean. The one wake lint warning (bodyon GET infetch) predates this change.[];metadadosand promotions with coupon initens[].ajustes./dashboard/*,/formasPagamento,/origensPedido,/centrosdistribuicao,/lojasFisicas) and thex-total-countheader. Their paths and params follow Wake's API reference. A wrong path would surface as a clearHTTP 404from the tool. I'll call each one on a real connection right after deploy.🤖 Generated with Claude Code
Summary by cubic
Adds order analytics to the Wake MCP:
WAKE_LIST_ORDERSnow reports totals, handles date-only ranges, and can project orders without personal data, plus new dashboard and reference tools and a per-token rate gate.Order listing improvements
total,page,pageSize, andhasMorefrom Wake'sx-total-countheader.2026-11-25) now means the whole day; previously a date-onlydataFinalended at midnight and returned nothing.direcaoOrdenacao,listaPedidosIds(up to 50 ids in one call),DataStatusfilter, andcamposAdicionais.fields: "analytics"returns a whitelist projection that drops buyer name, CPF, e-mail, phones, street address, card data, Pix QR code, and free-text notes; a field Wake adds later stays out until added to the projection.itemsandcountare unchanged;fieldsdefaults tofull.New tools and rate gate
WAKE_DASHBOARD(revenue, transactions, average ticket, payment methods, best sellers, abandoned carts),WAKE_LIST_PAYMENT_METHODS,WAKE_LIST_ORDER_ORIGINS,WAKE_LIST_DISTRIBUTION_CENTERS, andWAKE_LIST_PHYSICAL_STORES.Retry-Afterpasses, without reaching Wake. The refusal carries a[wake-rate-limited]error so callers can back off.Written for commit c4e6c74. Summary will update on new commits.