RYP-G3 in Wave P.
- @railyard/insights-web: page views (with client-side route changes),
events, identify, and LCP, INP, CLS, FCP and TTFB per page view, sent once
when the page is hidden or the route changes; no cookies, no storage, Do
Not Track and consent respected. src/metrics.ts adapts MIT-licensed code
(NOTICE keeps the licence) with two changes that match Chrome's field
reporting: LCP stops at the first input, and INP picks its percentile from
the page's interaction count. On six worked fixtures (after-click paint,
two shift windows with a post-input shift, prerender activation, 120
interactions, multi-event interactions) every metric and the p75 are
within 10% of Chrome's values.
- Edge collector and ingest carry `performance` events (the five metrics,
in the upstream ranges) into upstream event type 5 rows.
- Insights GET /api/v1/tenants/{org}/vitals: p75 per app, per UTC day, and
in the day before and after each given deploy time (up to 10); ratings
from the published thresholds; org-scoped (SQL test with hand p75s).
- Console: the Page speed screen (only with RAILYARD_REPLAY_LIVE=1) and the
Scribase bridge `insights` answer gain `vitals` (p75 cells and one marker
per deploy from the console's own deploy records, so a deploy is marked on
the next read); a vitals failure never hides the rest of the tab.
The Scribase Analytics sub-tab (carve-out) joins these markers to the
environment's error issues: "This deploy raised errors by N" links to the
Errors tab.
Tests: console 128/128 (view model, bridge marker, flag gate, copy lint),
insights-web 12/12 (fixtures, client, copy), insights fork 12/12, edge
19/19, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Railyard console
The signed-in console for Railyard (RYP-D1, Wave E package Y-2): sign in with Google or GitHub, a $1 card check that is credited back, a 14-day trial with the plan's limits, then one plan billed monthly or yearly. Three screens (Apps, Usage, Billing), one primary action on each, a pause switch and one-click cancel.
How it works
- Sign-in: the console's own Scribase project handles Google and GitHub (OAuth with PKCE). The console reads the user from the auth server, creates the org and its entitlements row, and keeps a signed, HttpOnly session cookie.
- Data: schema
railyardin the same Scribase project (db/migrations/0001_railyard_console.sql), reached with the service role from the server only. RLS is on with no policies. - Money ladder:
lib/ladder.ts(pure). Checkout sessions carry signed metadata, so a payment link with made-up metadata cannot name an org.lib/webhook.tsverifies the Standard Webhooks signature and timestamp, ignores replays (unique message id), applies the ladder, and credits or debits the $1 on the customer's wallet with idempotency keys. A refund of the card check reverses the credit and ends the trial. - CLI sign-in: a device flow at
/api/v1/device/codeand/api/v1/device/token; the user approves the code at/device. Tokens are org-scoped and stored as SHA-256 hashes. - Test mode only: the payment client refuses the live host unless
RAILYARD_DODO_LIVE=1is set by the owner.
Environment
| Name | Where | What |
|---|---|---|
SCRIBASE_URL |
var | The console's Scribase project URL |
SCRIBASE_ANON_KEY |
secret | Project anon key (sign-in calls only) |
SCRIBASE_SERVICE_ROLE_KEY |
secret | Project service role (schema railyard) |
RAILYARD_SESSION_SECRET |
secret | 32+ random bytes; signs sessions and checkout metadata |
DODO_API_KEY |
secret | Test-mode key of the railyard brand |
DODO_WEBHOOK_SECRET |
secret | Webhook signing secret (whsec_...) |
DODO_BRAND_ID |
var | Brand id; events for other brands are ignored |
DODO_PRODUCT_ID_CARD_CHECK, DODO_PRODUCT_ID_MONTH, DODO_PRODUCT_ID_YEAR |
var | The three products |
DODO_API_BASE |
var | Defaults to the test host |
RAILYARD_DODO_LIVE |
var | Owner only: 1 allows the live host |
RAILYARD_CONSOLE_URL, RAILYARD_INSIGHTS_URL |
var | Public URLs |
INSIGHTS_API_URL |
var | Insights tenant API base (Wave P PY1.3); empty keeps the Insights page on "No data yet" |
FLAGS_API_URL |
var | Railyard Flags (Wave P PY2.1): base URL of the flags service on box 2 (through the tunnel). With FLAGS_ADMIN_TOKEN set, new flag environments are made there; without them, flags live in the console's own tables (migration 0005), the fallback. |
FLAGS_ADMIN_TOKEN |
secret | The flags service's instance admin token (Token ... auth). Only this console holds it; apps read flags with their public flags key. |
RAILYARD_WATCH_LIVE |
var | Railyard Watch (Wave P PY2.2). 1 turns on uptime checks, the Watch screen, the public status pages and the alert email. Unset (the default): no check runs and nothing about Watch is shown (denylist rule railyard-slot-watch). Set it only after the customer checks stack on box 1 passes its drill. |
WATCH_AGENT_TOKEN |
secret | Bearer token of the box 1 checks agent (stacks/gatus-customers/agent.sh), at least 32 characters; the same value sits in /etc/products/watch-agent.token on box 1. Unset keeps the agent API off (503). |
RAILYARD_REPLAY_LIVE |
var | Insights depth (Wave P PY3.2) and web vitals (PY3.3). 1 serves /api/v1/insights/* (profiles, cohorts, retention by property, breakdowns, CSV and JSON export, delete by user id) to an org's ry_ token, and the vitals views. Unset (the default): those answer 503 "arriving" (denylist rule railyard-slot-replay). Identify events are stored either way. |
RAILYARD_SHIP_ON_PUSH_LIVE |
var | Ship on push (Wave P PY3.1, ADR RY-0004). 1 turns on railyard link, the GitHub and Cloudflare browser steps and the railyard ci exchange. Unset (the default): every /api/v1/github/* route answers 503 "not switched on" (denylist rule railyard-slot-ship-on-push). |
GITHUB_APP_ID, GITHUB_APP_SLUG |
var | The Railyard GitHub App (owner item Y4, created from /api/v1/github/manifest). |
GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET |
secret | The App's key (PKCS#1 as GitHub issues it, or PKCS#8) and its webhook secret. Stored by the command the manifest page shows; never displayed. |
CLOUDFLARE_OAUTH_CLIENT_ID |
var | Our Cloudflare OAuth client (public, domain verified), redirect <console>/api/v1/github/cloudflare/callback. |
CLOUDFLARE_OAUTH_CLIENT_SECRET |
secret | Its client secret. |
CLOUDFLARE_OAUTH_SCOPES |
var | Optional: the scope ids configured on that client, space or comma separated. Default: account read, user read, Workers and Workers scripts and routes write, offline_access. |
RALLY_TX_URL |
var | Rally Send transactional endpoint (https) for Watch alert email, product railyard. |
RALLY_TX_KEY |
secret | Rally Send key minted for product railyard. Without it, alerts are logged, not sent. |
INSIGHTS_API_TOKEN |
secret | Bearer token of the Insights tenant API |
SITES |
KV binding | The edge collector's site entries; written when an app is added and on every plan, add-on or pause change |
RELAY_URL |
var | Relay's OpenAI-compatible base for the AI gateway (Wave P PY1.4) |
RELAY_TENANT_KEY |
secret | The Relay tenant key from relay-tenancy.sh tenant-key (BYOK only; see apps/relay/config/tenants/README.md) |
RAILYARD_CREDENTIALS_KEY |
secret | 32 random bytes, base64: seals customers' provider keys |
RAILYARD_SCRIBASE_BRIDGE_SECRET |
secret | Standard Webhooks secret (whsec_...) shared with Scribase control-api for the bridge (Wave P PY1.0). Unset keeps the bridge off (503). |
RAILYARD_BRIDGE_ACCEPT_LEGACY |
var | P-Y1 transition only. 1 also accepts bridge calls from a Scribase build older than contract version 2 (message id without the route, orgs without addon.as_of). Unset (the default) refuses them. Set it only for the minutes between the console deploy and the Scribase control-api deploy, then remove it. |
Scribase bridge (Wave P PY1.0)
Scribase sells Railyard inside its portfolio add-on. Its control-api calls
/api/v1/bridge/scribase/{orgs,claims,proof}, server to server and signed
(app/api/v1/bridge/scribase/service.ts). The first call creates the Railyard
org bound to the Scribase org id (no second sign-up, table
railyard.scribase_bindings, migration 0002), and the add-on state is
mirrored into the entitlement as plan addon. A lapsed add-on pauses the org
and keeps its data. Keys reach only the Scribase CLI: a claim is a one-time,
pre-approved device code that the CLI exchanges at /api/v1/device/token and
writes to the credentials file. The contract is
tests/contract/fixtures/scribase-bridge/contract.json at the repo root.
Tests
pnpm install --filter @railyard/console
node --test test/*.test.ts # journey, webhook, ladder, tokens, repo, component, bundle, migration
The journey test runs sign-in, the $1 checkout, the webhook and "Add app" against
in-memory fakes of the payment and auth servers. The bundle test runs
next build with sentinel secrets and greps the client bundle. The migration
test starts a throwaway local Postgres.
Owner steps
- Create the
railyardbrand and the three test-mode products; set the env above. - Apply
db/migrations/0001_railyard_console.sql, thendb/migrations/0002_scribase_bridge.sqlanddb/migrations/0003_ai_gateway.sql, to the console's Scribase project and addrailyardto its exposed schemas. - Enable Google and GitHub sign-in on that project with
https://railyard.ereboslab.com/auth/callbackas a redirect URL. - Point the webhook at
/api/billing/webhook, then run one card check and one refund in test mode and record the result.