@hkarthi10/flagsmith-flight-check
v0.1.0
Published
Doctor + guard CLI for self-hosted Flagsmith Experimentation (Toggle Wars hackathon)
Maintainers
Readme
Flight Check for Flagsmith Unofficial community tool for Flagsmith; not affiliated with or endorsed by Flagsmith.
Self-hosted Flagsmith experiments can look healthy while their events never arrive. Flight Check probes the event pipeline on a local instance; Feature Health reporting is implemented per the documented webhook schema but not yet verified on a live instance.
Quick start
npx @hkarthi10/flagsmith-flight-check init
npx @hkarthi10/flagsmith-flight-checkLocal setup lives in .env; FLAGSMITH_* environment variables are for CI only. In non-interactive shells, npx @hkarthi10/flagsmith-flight-check init --yes writes flight-check.json placeholders instead. The environment key is never printed; only its first four characters appear as ABCD….
Requires Node >=20.12.0; CI tests Node 20 and 22 (the .env loader uses process.loadEnvFile when available, with a parser fallback). The Flagsmith JS SDK used by the simulator is 12.6.0.
npx @hkarthi10/flagsmith-flight-check --ci # no colors, no prompts, exit 1 on any FAIL
npx @hkarthi10/flagsmith-flight-check --json # machine-readable resultsThe example workflow in examples/example-flight-check.yml runs npx @hkarthi10/flagsmith-flight-check --ci with values from GitHub secrets; copy it into .github/workflows/ to use it.
Docker image (untested)
The Docker image has not been tested against a host Flagsmith instance. A container needs host.docker.internal to reach Flagsmith on the host.
bash:
docker build -t flight-check .
docker run --rm --add-host=host.docker.internal:host-gateway -v "$PWD:/work" flight-check --ciPowerShell:
docker build -t flight-check .
docker run --rm --add-host=host.docker.internal:host-gateway -v "${PWD}:/work" flight-check --ciSample output
$ npx @hkarthi10/flagsmith-flight-check
Flight Check doctor
Config: apiUrl=http://localhost:8000/api/v1 (.env) | eventsUrl=http://localhost:8000/api/ (.env) | envKey=ABCD… (.env)
[PASS] API URL: Using http://localhost:8000/api/v1
[PASS] API reachability: HTTP response from http://localhost:8000/api/v1.
[PASS] events URL: Events will be sent to http://localhost:8000/api/v1/events
[INFO] event timestamp: Reminder: events older than 10 days or more than 24h ahead are rejected.
[INFO] batch size: Reminder: batches over 2 MiB are rejected.
[PASS] environment key: Loaded (ABCD…).
[PASS] synthetic event round trip: Endpoint accepted the probe (HTTP 202) at http://localhost:8000/api/v1/events
Manual checklist (cannot be detected remotely):
[ ] EXPERIMENTATION_ENABLED=true is set on the API (otherwise the Warehouse tab does not appear).
[ ] Storage mode chosen: Flagsmith Postgres (evaluation only) or your own warehouse.
[ ] SDK initialised with enableEvents: true and an identified user.
[ ] Flags read via getExperimentFlag (plain getValue records no exposure).
RESULT: READYWhy this exists
I read the self-hosting docs and the SDK source, found that events default to Flagsmith Cloud and that a rejected key stops tracking, reproduced this against a local instance, then built the check.


What doctor checks
doctor resolves config in this order: CLI flags, FLAGSMITH_* environment variables (CI only), .env in the working directory, then flight-check.json (apiUrl, eventsUrl, envKey).
Uses the same events endpoint as the SDKs; event shape verified against the JS SDK 12.6.0 only. doctor only speaks HTTP to the events endpoint (POST <eventsUrl>v1/events with X-Environment-Key). It checks the API URL, GET reachability, the events URL, timestamp-window and batch-size rules as [INFO] reminders, then posts one synthetic event. The reminders state that events older than 10 days or more than 24h ahead are rejected and batches over 2 MiB are rejected; INFO does not count as a problem. If the events URL or API check fails, the probe is skipped. Failing checks print a fix hint and the last line is always RESULT: READY, RESULT: NOT READY (1 problem), or RESULT: NOT READY (N problems).
On a real self-hosted Flagsmith instance (Docker, local), the synthetic event got HTTP 202 and the Warehouse "Total events received" rose by exactly 1 per doctor run. Each doctor run adds one flight_check_probe event to the Warehouse. Pointing the events URL at Flagsmith Cloud returned HTTP 403 "Unknown environment key".
npx @hkarthi10/flagsmith-flight-check doctor --api-url http://localhost:8000/api/v1 \
--events-url http://localhost:8000/api/ --env-key "$FLAGSMITH_ENV_KEY"Plan and guard
plan
Rough frequentist sample-size and days-to-decision estimate; Flagsmith's results engine is Bayesian, so treat this as planning guidance only.
npx @hkarthi10/flagsmith-flight-check plan --baseline 0.05 --lift 0.2 --daily 400guard
Evaluates a per-arm bad-event rate, then reports healthy/unhealthy to Feature Health through the Webhook provider.
npx @hkarthi10/flagsmith-flight-check guard --exposures 500 --bad 40 --arm Variant_1 --min 100 \
--feature checkout_button --webhook-url "$FLAGSMITH_HEALTH_WEBHOOK" \
--environment Development--webhook-url may come from FLAGSMITH_HEALTH_WEBHOOK. guard --from-json <tally.json> evaluates every arm in a simulator tally; --error-arm <name> picks the arm reported to Feature Health. The Admin API kill sequence is not implemented against the real API; only the interface and the rollout-to-0%-then-pause ordering exist in src/guard.ts.
simulator
sim/simulate.mjs uses the real Flagsmith JS SDK 12.6.0 to enroll identities, record exposures, and send events.
node sim/simulate.mjs --env-key "$FLAGSMITH_ENV_KEY" --flag checkout_button \
--users 300 --event purchase \
--rates control=0.10,Variant_1=0.16 --errors Variant_1=0.40 --seed 42Arm names in --rates and --errors are case-insensitive; unmatched keys produce a loud warning and the arms actually seen are printed after the run. --errors fires checkout_error events to demo a bad variant, --seed makes a run repeatable, and --json <path> writes a tally file for guard --from-json. --dry-run still calls getExperimentFlag and tallies locally, but initialises the SDK with enableEvents: false and no eventProcessorConfig, so no events are sent; on a live Docker instance it left the Warehouse total unchanged. examples/bad-tally.sample.json shows the tally shape, and sim/mock-server.mjs is a fake Flagsmith for offline testing.
Track 01 experiment
In simulated traffic, a redesigned checkout button (Variant_1) will raise purchase conversion from 10% to 18% versus control, reaching at least 95% win probability within a single 600-user run.
Metric: Purchase Conversion.
As of 28 Nov 2026 07:25 UTC, simulated traffic enrolled 600 users into a running experiment: 292 control and 308 Variant_1. The Flagsmith results page computed 8.6% vs 16.6%, +93.4% lift, 98% chance to be best, and a 95% credible interval of [6.0%, 180.8%]. The 98% result meets the hypothesis; observed rates (8.6% and 16.6%) differ from the simulated 10% and 18% by chance. The interval is wide because the sample is small. simulate --dry-run left the Warehouse total unchanged.


How Flagsmith is used
Self-hosted Docker: follow the official Docker guide:
bash:
curl -o docker-compose.yml https://raw.githubusercontent.com/Flagsmith/flagsmith/main/docker-compose.yml docker compose upPowerShell:
curl.exe -o docker-compose.yml https://raw.githubusercontent.com/Flagsmith/flagsmith/main/docker-compose.yml docker compose upThe UI is at
http://localhost:8000, the SDK API athttp://localhost:8000/api/v1/, and the events URL athttp://localhost:8000/api/(the SDK appendsv1/events).Experiments: the running "Checkout Button Final" experiment used the real arm names
controlandVariant_1.SDK events: the simulator initialises with
enableEvents: trueandeventProcessorConfig.eventsApiUrl, identifies the user, callsgetExperimentFlag,trackEvent, andflushEvents. Events POST to<eventsApiUrl>v1/eventswith theX-Environment-Keyheader and epoch-millisecond timestamps. Event shape is verified against the JS SDK 12.6.0 only.Feature Health webhook:
guardposts{feature, status, environment, reason}per the documented webhook schema; live verification is outstanding.
Limitations
- The Feature Health webhook is not yet verified on a live instance.
- The Admin API kill sequence is not implemented against the real API; only the interface and the rollout-to-0%-then-pause ordering exist in src/guard.ts.
- The Docker image run against a host Flagsmith instance is not yet verified.
- SDKs other than JS 12.6.0 are not yet verified.
- guard evaluates numbers you give it (flags or a tally file); it does not read live Flagsmith results and cannot end an experiment.
- doctor confirms the server accepted the probe; it does not read the Warehouse counter, so ingestion was confirmed by hand.
Development
npm ci && npm run build
npm test # tsc + node:test (CLI checks and simulator helpers)sim/ and scripts/ are repo-only demo tools that need git clone + npm ci && npm run build to run locally. On Windows you can also use flight-check.bat, which calls dist/src/cli.js. Never commit environment keys or webhook URLs; pass them via the config sources above at runtime. .gitignore excludes flight-check.json, .env, brain*.md and *-tally.json.
License
MIT
