Skip to content

feat: add UI capture sample shops for React, Next.js and plain HTML - #116

Merged
slayerjain merged 2 commits into
mainfrom
feat/ui-capture-sample-shops
Nov 20, 2026
Merged

slayerjain merged 2 commits into
mainfrom
feat/ui-capture-sample-shops

Conversation

@slayerjain

@slayerjain slayerjain commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Adds three sample apps for Keploy UI capture: one small shop built three ways, each recorded in the browser with @keploy/capture-sdk (pinned to 3.1.0). All three have the same pages (Home, Products with a search box, Cart, Checkout, About), the same data-testids and the same /api routes.

Folder Stack What it shows
ui-capture-react-shop React 19, Vite 8, React Router 8 src/keploy.ts imported first in src/main.tsx; privacyMode: "balanced" written out, with maskSelectors, blockSelectors and a commented secretRoutes; an onError that ignores KUI_E_CAPTURE_DECLINED; logs its session id. One session per visit, every route change recorded with its cause.
ui-capture-next-shop Next.js 16 App Router init() from instrumentation-client.ts, before hydration; NEXT_PUBLIC_ variables; client components that fetch in the browser; Next's own ?_rsc= fetches are recorded too.
ui-capture-html-shop plain HTML, no bundler the SDK's dist/ served as npm installed it, with an import map for rrweb; keploy.js loaded as its own async module script. Every page load is a session of its own.

Each folder has:

  • a README: run it in four commands, where the ingest key goes, and what is recorded and masked;
  • a .env.example with placeholders, and a lockfile;
  • npm run demo:visits: five scripted visits in headless Chromium. The two single-page shops end each visit and mark it complete (POST /ui/v1/sessions/<id>/complete), so it becomes flows at once.
  • npm test: a Playwright smoke test against a local fake ingest (test/fake-ingest.mjs). No Keploy account or key is needed. It checks:
    • every batch carries the pinned SDK version;
    • every page, route change, click and request made once the capture is recording arrives;
    • the search is recorded as sent (?q=kettle, which balanced keeps);
    • the email in the order's body is redacted;
    • typed values are asterisks;
    • the masked confirmation, the blocked reviews and the key appear nowhere;
    • demo:visits records every visit whole.

The shops never hold their own requests back until the SDK is recording, so the SDK never slows them. A request a page makes while init() is still loading rrweb is not recorded, as the SDK's README says. Each README says so, and npm test prints whether each page's load request made it.

One GitHub Actions workflow per folder (.github/workflows/ui-capture-*-shop.yml) runs npm ci, the build and npm test on Node 22.22 and 24, for changes to that folder only. No secrets are used.

Verified before opening:

  • npm test for all three folders: run on Linux with npm ci, the build and npm test, as CI does: 6 of 6 pass, on 3.1.0-rc.2 and again on 3.1.0.
  • The three shops against a deployed Keploy environment (with 3.1.0-rc.2, before the bump to 3.1.0): each used its own disposable app, built with a freshly minted ingest key, and was driven by its own npm run demo:visits.
    • Results:
      • Every app reached FLOWS_READY.
      • React and Next.js: 5 sessions and 15 flows each.
      • Plain HTML: 15 sessions and 15 flows, ended by the server's idle window.
    • The flow names were the same for all three shops: Click on /, Click on /cart, Click on /products, Fill on /checkout, Fill on /products, Navigate on /about, Navigate on /cart.
    • Clean-up: each app's key was revoked and the app deleted afterwards.

The root README lists the three samples.

One small shop built three ways (React + Vite + React Router, Next.js App
Router, plain HTML pages with no bundler), each recorded in the browser
with @keploy/capture-sdk, pinned to 3.1.0-rc.2. They share the same
pages, data-testids and /api routes, so their flows carry the same names.

Each folder has a README (run it, where the ingest key goes, what is
recorded and masked), a .env.example with placeholders, a lockfile,
`npm run demo:visits` (five scripted visits; the single-page shops mark
each visit complete so it becomes flows at once) and `npm test`: a
Playwright smoke test against a local fake ingest. It checks that the
pinned SDK version is sent, that every page, click and request made once
the capture is recording arrives, that typed values are masked, that the
order's email is redacted, that the blocked and masked regions and the
key appear nowhere, and that demo:visits records every visit whole.

The shops never hold their own requests back for the SDK, so a request a
page makes while init() is still loading rrweb is not recorded; the
READMEs say so and the test prints whether each load request made it.

A GitHub Actions workflow per folder runs install, build and the smoke
test on Node 22.22 and 24 for changes to that folder. No Keploy
credentials are needed or stored.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@keploy/capture-sdk 3.1.0 is on npm's latest tag. Pin it exactly in the
three shops' package.json, in place of 3.1.0-rc.2.

Each lockfile is regenerated for the new pin with npm install
--package-lock-only against the existing lockfile, so only the SDK's
lines change: the root entry's pin, and the SDK entry's version, tarball
and integrity. 3.1.0 depends on rrweb ^2.1.6 as the rc did, so no other
locked package moves.

For all three folders, npm ci, the build where the folder has one and
npm test pass (6 of 6), the tests checking that every batch carries the
pinned 3.1.0.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain merged commit 6231b4e into main Nov 20, 2026
7 checks passed
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.

1 participant