Add agent-commerce-analytics-template: merchant dashboard for AI agent traffic#971
Open
mconroy-cf wants to merge 3 commits intocloudflare:mainfrom
Open
Add agent-commerce-analytics-template: merchant dashboard for AI agent traffic#971mconroy-cf wants to merge 3 commits intocloudflare:mainfrom
mconroy-cf wants to merge 3 commits intocloudflare:mainfrom
Conversation
Merchant-facing analytics dashboard for AI shopping agents. Tracks the full discover -> browse -> purchase journey per agent, payment network, and verification status, and surfaces auto-generated insights (top agent, product gaps, blocked checkouts, repeat visitors) in a React SPA at /. - Required EVENT_STORE KV binding; events keyed with reversed-timestamp prefix so list() returns newest-first without a sort step - @cloudflare/vite-plugin pattern: SPA at /, Worker owns /api/* - DELETE /api/events is gated behind an optional ADMIN_TOKEN secret (403 when the secret isn't set) - Batch ingestion capped at 500 events, KV writes/deletes chunked to stay well under the Workers subrequest limit - Bundled demo seed (5 agents, 19 events) on first dashboard request via a long-TTL KV marker; disabled with SEED_DEMO_DATA=false - 10 vitest tests via @cloudflare/vitest-pool-workers - Playwright e2e spec under playwright-tests/ Registered in templates.json.
deloreyj
reviewed
Apr 24, 2026
Contributor
deloreyj
left a comment
There was a problem hiding this comment.
Thanks for this — smoke-tested the worker locally and the analytics pipeline all works (seed data populates, event ingestion writes, admin-token gate behaves correctly). Several things to address before merge:
- Missing Deploy to Cloudflare button in
README.md—validate-d2c-buttonswill fail CI. Add this at the very top:[](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/main/agent-commerce-analytics-template)
- No
<!-- dash-content-start -->/<!-- dash-content-end -->markers — without them, the Cloudflare Dashboard template gallery won't have a blurb to show. Wrap a short overview section (probably a tightened version of "What This Does") in the markers. README.md:66-74references scripts that don't exist —npm run walkthrough,simulate, anddashboardaren't inpackage.json, so users will hitUnknown script. Either add them or remove from the README.gitlab.cfdata.orglinks 404 for external viewers — the "Part of the agent-commerce portfolio" note at the top and the table at the bottom. Describe the portfolio inline or link only to public pieces.Live dashboard:points atmattrc07.workers.dev— once the Cloudflare team provisions the live demo, it'll be athttps://agent-commerce-analytics-template.templates.workers.dev. Update it then, or drop the line for now.
- Add Deploy to Cloudflare button at the top so validate-d2c-buttons passes - Wrap overview blurb in dash-content-start/end markers for the dashboard gallery - Replace Quick Start with the scripts that actually exist in package.json - Drop gitlab.cfdata.org links (404 for external viewers) and describe the portfolio inline - Drop the mattrc07.workers.dev live dashboard line; the provisioned URL can replace it later
Author
|
Thank you for the feedback, James! Made the desired changes |
Captures the four trust signals merchants triage on (Web Bot Auth, signed-agents managed list, KYA token, UA-only) on every event, derives a verified / claimed-only / unverified tier, and exposes the rollup at GET /dashboard/trust. The 'verified: boolean' field is preserved for back-compat with existing dashboards/clients; new code consumes 'trustSignals.trustTier'. The POST /events/from-headers endpoint now derives signals automatically from request headers, so deploying behind a Worker that already runs Web Bot Auth or a KYA-emitting Managed Ruleset just works. README updated with a 'Trust signals' section explaining the four signals, the three-tier rollup, and which header inputs each derives from. Verification: - pnpm run check:templates pass - pnpm run check:prettier pass - pnpm test 10/10 pass
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.
Summary
Adds
agent-commerce-analytics-template— a merchant-facing analytics dashboard for AI shopping agents. Tracks the full discover → browse → purchase journey per agent, payment network, and verification status, and surfaces auto-generated insights (top agent, product gaps, blocked checkouts, repeat visitors) in a React SPA at/.Pairs with
commerce-llms-txt-templateon the visibility side — where commerce-llms-txt makes a merchant's catalog agent-readable, this template gives the merchant visibility into what the agents are actually doing.What's in the template
src/analytics-worker/index.tsserving/api/dashboard{,/funnel,/agents,/products},/api/events{,/batch,/from-headers}, and an/apidocs endpoint.src/react-app/via@cloudflare/vite-plugin— funnel, agent table, per-agent journey timelines, product performance, headline cards, and a before/after comparison with generic zone analytics.EVENT_STOREKV binding with a placeholder ID inwrangler.jsonc. Events persist underevent:<reversed-timestamp>:<random>solist()returns newest-first without a sort step; per-event TTL is controlled byEVENT_RETENTION_DAYS.DELETE /api/eventsis gated behind an optionalADMIN_TOKENsecret; disabled (403) when the secret isn't set.SEED_DEMO_DATA=false.@cloudflare/vitest-pool-workers, including coverage for the admin-token gate.playwright-tests/agent-commerce-analytics-template.spec.ts.Applying feedback from #968
Both new templates pre-apply the KV-required + SPA-on-top-of-API feedback from #968.
Verification
pnpm turbo run check --filter=agent-commerce-analytics-template— passespnpm turbo run test --filter=agent-commerce-analytics-template— 10/10 passingpnpm run check:templates— passespnpm run check:prettier— clean