Start here
Quickstart: capture to verified fix
About 30 minutes. You'll generate an SDK token, install the CLI, capture a planted bug in one of the demo apps, replay it to REPRODUCED, fix it, and verify to FIXED. Then move the same steps to your own app.
Before you start
You need a BugCapsule project and two things from its dashboard: an SDK token (bcsdk.v1.…) for apps, and a personal CLI token for the bugcapsule CLI. The SDK token is client-visible and can only send data, so it may ship inside apps. The CLI token acts as you; it never goes into an app.
| For | You need |
|---|---|
| CLI | Node.js 20+ for npm installation, or a standalone executable; git for source-pinned replay |
| Flutter / iOS demo | Xcode with an iOS simulator |
| Android demo | Android SDK, an emulator (API 35 tested), JDK 17 |
| Web demo | Node 20+; your origin allowed by your BugCapsule team (see Web) |
1. Generate an SDK token
Onboarding in the dashboard walks you through it: Create project → Generate token → Install SDK → Paste init snippet → Confirm connection. You can also generate one later in Project Settings › Keys › SDK tokens. The token is shown once, so copy it straight away. It carries your BugCapsule address and an ingest-only credential, so it is the only value an app needs, for hosted and self-hosted BugCapsule alike. Generating tokens needs the Admin or Owner role.
In your own app the connection is one line:
void main() => BugCapsule.init(
config: const BugCapsuleConfig(token: 'bcsdk.v1.…'),
appRunner: () => runApp(const MyApp()),
);
// First thing in Application.onCreate
BugCapsule.init(this, BuildConfig.BUGCAPSULE_TOKEN)
// First line of application(_:didFinishLaunchingWithOptions:), or App.init
BugCapsule.start(token: "bcsdk.v1.…")
await BugCapsule.init({ token: 'bcsdk.v1.…' }); // before rendering
renderApp();
Start the app and watch the onboarding's Confirm connection step. It shows two separate confirmations:
- Configuration fetched: the app reached BugCapsule with a valid token. Address, token and network are right.
- First event or Capsule received: captured data reached your project. Capture works end to end.
The app can tell you the same through its status API (BugCapsule.status on Flutter and iOS, BugCapsule.status() on Android and web), including why it isn't connected: an invalid token, a revoked or expired one, or no network. A token problem never stops your app from starting. Being connected is not complete replay yet: network, navigation and app-state adapters are the next steps on each platform page.
Self-hosted or existing setups (advanced)
Projects set up before SDK tokens use an explicit API URL and ingest key (bci_…) in the app instead of a token. That keeps working on every platform; each platform page shows the advanced form. A self-hosted BugCapsule issues tokens with its own address, so it doesn't need the explicit form. Never put a bcs_ secret key in an app.
2. Install the CLI and log in
Install the published CLI from npm. See Installation for platform requirements and PATH setup. bugcapsule login opens your browser: check the code matches your terminal, pick the project and approve.
npm install -g @bugcapsule/cli@0.4.1
bugcapsule login # opens your browser to approve
bugcapsule list # empty for a new project
Details and alternatives: CLI install.
3. Capture the first capsule
Obtain the SDK repository for your platform from your BugCapsule team and pick its demo. Commands below assume sibling SDK checkouts; start each platform section from their parent directory. Replace device IDs and the token before running. The Flutter, iOS and web demos share a planted bug: a coupon SAVE100 that takes a fixed 100 off, so a cart under 100 gets a negative total and fires check("cart_total_non_negative").
cd bug_capsule_flutter_sdk/example/bug_capsule_demo
flutter run -d <simulator> \
--dart-define=BUGCAPSULE_GIT_SHA=$(git rev-parse HEAD) \
--dart-define=BUGCAPSULE_TOKEN=bcsdk.v1.…
Open the cart until the subtotal is below $100, type SAVE100, apply.
cd bug_capsule_android_sdk
BUGCAPSULE_SDK_TOKEN=bcsdk.v1.… ./gradlew :demo:installDebug
The demo reads the SDK token from BUGCAPSULE_SDK_TOKEN. Don’t put an SDK token in BUGCAPSULE_TOKEN: that variable is the CLI’s own credential and would replace your CLI login.
On Android, use the race bug, whose fix toggle verifies cleanly: tap Refresh home until the app crashes (~1 in 4, recommendations arrive before the profile). The crash capsule is written synchronously and uploaded on the next launch, so open the app again. The project folder for the CLI is examples/demo.
cd bug_capsule_ios_sdk/Examples/Demo
xcodebuild test -project BugCapsuleDemo.xcodeproj -scheme BugCapsuleDemo \
-destination 'id=<simulator udid>' -collect-test-diagnostics never \
BUGCAPSULE_TOKEN=bcsdk.v1.… \
-only-testing:BugCapsuleDemoUITests/CaptureFlowTests/testCaptureNegativeTotal
The UI test drives the app into the bug for you.
cd bug_capsule_web_sdk && npm install && npm run build
node examples/shop/api-server.mjs & # the demo shop's own API on :4318
cd examples/shop
VITE_BUGCAPSULE_TOKEN=bcsdk.v1.… \
VITE_BUGCAPSULE_ALLOW_REPLAY=true npx vite build && npx vite preview --port 4317 --strictPort
Open http://127.0.0.1:4317/, build a cart under 100, apply SAVE100. Stop the preview server before replaying: the CLI refuses to start when something already serves the app URL.
The app writes a capsule and uploads it. The upload waits until the app has fetched its capture settings once (the Configuration fetched confirmation), so give it a second. The demos also accept the advanced URL + ingest key pair (BUGCAPSULE_BACKEND_URL + BUGCAPSULE_INGEST_KEY; VITE_-prefixed on web), which wins over the token when set.
bugcapsule list # status new, eligibility eligible
bugcapsule inspect <id> # failure, eligibility, network, timeline
bugcapsule inspect <id> --json | less # check nothing is in there that shouldn't be
4. Replay it
Run from the demo's project folder (or pass -p):
bugcapsule run <id> -n 3 # add -d <simulator|avd> to pick a device
Expected: REPRODUCED 3/3, exit 0, capsule status reproduced. If you get INCONCLUSIVE, the output lists why (for example an action id that isn't registered in the replayed build); see Troubleshooting.
5. Fix and verify
Fix lib/shop.dart: clamp the coupon discount to the subtotal. Then:
bugcapsule verify <id> -d <simulator> -n 5
The demo has build-time fix toggles (race, price, legacy), so no source change is needed. Only race keeps the recorded request sequence; the others change which requests the app makes and verify as INCONCLUSIVE by design.
BUGCAPSULE_ANDROID_GRADLE_ARGS=-PbugcapsuleDemoFix=race bugcapsule verify <id> -p examples/demo -n 3
BUGCAPSULE_IOS_BUILD_SETTINGS='DEMO_FIXES=FIX_NEGATIVE_TOTAL' bugcapsule verify <id> -n 3
Set the demo's fix toggle in the build environment:
VITE_BUGCAPSULE_DEMO_FIX=coupon bugcapsule verify <id> -n 3
Expected: FIXED — failure gone in N/N valid runs, exit 0, status fixed. Anything less than every requested attempt running validly is INCONCLUSIVE (exit 3) and doesn't change the status.
6. Keep it as a regression test
bugcapsule regress add <id> --name "coupon over subtotal"
bugcapsule regress run # exit 1 if any test fails; wire it into CI
Next: run regressions in CI.
Now do it in your own app
- Paste the one-line token setup from step 1, start the app, and wait for both confirmations.
- Or let a coding agent do the install, connection and adapters: copy the prompt for your platform from Set up with an AI agent.
- Add the progressive adapters for complete replay (network, navigation, app state) per your platform page (Flutter, Android, iOS, Web); the status API lists the ones still
missing. Then register action ids for the flows QA tests most. - Pass the git SHA in every build, production release builds included; set mode
qain QA builds only. Keep production capture off until the production checklist passes. - Before the first upload from a real user, review redaction with a real login and payment flow and add
redactKeys/redactPatterns/excluderules. See Privacy & redaction.
What success proves
A completed demo proves the capture → replay → verify workflow for that demo and environment. Before using your own app, follow the integration checklist, especially state restoration, request matching and monitoring settings. A manual capture without an assertion is useful for inspection but does not prove a fix.