Adopts rrweb + rrweb-player (MIT, vendored as prebuilt UMD bundles via scripts/vendor-rrweb.mjs, see NOTICE) to add cookieless session replay to Railyard Insights, gated behind the existing Dodo paid tier. - src/replay/config.mjs: per-site settings with privacy-first floors/defaults (off by default, sample rate, maskAllInputs, maskTextSelector, per-session byte/duration caps, monthly session cap) — every cap is clamped server-side regardless of what a site's stored config asks for. - src/replay/ingest.mjs: POST /api/replay chunk ingestion — bot/DNT/GPC drop, paid-tier + enabled gate, hostname check, and all caps enforced again on the server (not just trusted from the client). - src/replay/store.mjs: D1 replay_sessions metadata + R2 event chunks (<siteKey>/<sessionId>/<seq>.json); wired into the existing site-delete flow so deleting a site removes its sessions too. - src/replay/tracker.mjs, routes.mjs, pages.mjs: the opt-in /replay.js tag, the dashboard's settings + session list + player pages (matching the existing Insights dashboard design), and the events API — all behind the same private dashboard token, so a site owner can only ever see and play back their own site's sessions. - wrangler.jsonc: new R2 binding (railyard-insights-replay). Tests: 23 new (config validation/clamping, ingestion caps, dashboard auth scoping, a regression test for the vendored player's actual constructor shape) + existing 52, all 75 passing. Verified end-to-end locally with wrangler dev + a real browser: recorded a session, played it back with rrweb-player, screenshots in /tmp/railyard-replay-*.png. No deploy, no merge to railyard main from this commit alone (see plans/railyard.md for the deploy/rollback steps). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
559 B
JSON
21 lines
559 B
JSON
{
|
|
"name": "@railyard/insights-edge",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"description": "Railyard Insights edge collector (Cloudflare Worker, RYP-D3).",
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "wrangler dev",
|
|
"deploy": "wrangler deploy",
|
|
"test": "node --test test/*.test.mjs test/replay/*.test.mjs",
|
|
"load": "node test/load.mjs",
|
|
"vendor:rrweb": "node scripts/vendor-rrweb.mjs"
|
|
},
|
|
"devDependencies": {
|
|
"miniflare": "5.20260923.0-alpha",
|
|
"rrweb": "2.1.7",
|
|
"rrweb-player": "2.1.7",
|
|
"wrangler": "4.139.0"
|
|
}
|
|
}
|