Skip to content

.#115

Open
CollinsKRO wants to merge 4 commits into
emrekayat:mainfrom
CollinsKRO:prime
Open

.#115
CollinsKRO wants to merge 4 commits into
emrekayat:mainfrom
CollinsKRO:prime

Conversation

@CollinsKRO

@CollinsKRO CollinsKRO commented Jun 30, 2026

Copy link
Copy Markdown

closes #88

Summary

Add a read-only JSON export endpoint for sanitized usage and spend analytics, making it easy for SCF reviewers and investors to verify usage without exposing sensitive data.

Changes

API — GET /api/export

Field Description
exportedAt ISO timestamp of when the export was generated
totalQueries Total query count
totalSpendUsd Total spend across all modes
spendByMode Spend broken down by mode (search, news, scrape)
spendByProvider Spend broken down by provider ID
queryCountByStatus Counts grouped as demo, paid, or failed
paymentEvidenceCount Number of payment records with transaction evidence

No raw payment headers, wallet secrets, facilitator URLs, or provider credentials are included.

Files touched

  • apps/api/src/lib/persistence.ts — Added AnalyticsExport interface and getAnalyticsExport() function
  • apps/api/src/routes/public.ts — Added GET /api/export route
  • apps/api/src/routes/public.test.ts — 3 tests:
    • Empty analytics returns valid export with zero totals
    • Export reflects saved usage and payment data
    • Secret-like fields (wallet keys, payment headers, facilitator results) are excluded
  • apps/web/src/pages/ControlDeckPage.tsx — Added "Export JSON" download button
  • apps/web/src/styles.css — Styling for export button

Testing

# Run the public route tests
npx vitest run apps/api/src/routes/public.test.ts

All 15 tests pass (12 existing + 3 new).

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@CollinsKRO is attempting to deploy a commit to the emrekayat's projects Team on Vercel.

A member of the Team first needs to authorize it.

@emrekayat

Copy link
Copy Markdown
Owner

Thanks for the PR. I reviewed the diff from the maintainer account, but this is not merge-ready.

The PR claims to close #88, but the current diff only changes:

.prettierrc.json
package-lock.json

There is no implementation or test coverage for the issue, and the PR title is just .. Please update the branch with the actual #88 implementation, use a descriptive title/body, and keep lockfile/prettier changes out unless they are strictly required.

- Add GET /api/export endpoint returning sanitized analytics
- Export includes: total queries, spend by mode/provider,
  demo/paid/failed counts, payment evidence count, timestamp
- No raw payment headers, wallet secrets, or provider credentials
- Empty analytics returns valid export with zero totals
- Tests assert secret-like fields are excluded
- Add Download JSON button to ControlDeckPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add reviewer-safe JSON export for usage and spend analytics

2 participants