Use BugCapsule
Using BugCapsule with Sentry
Keep Sentry where you track errors and issues. BugCapsule records the replayable Capsule for the same failure, links the Sentry event and the Capsule, and shows the reproduction and verification result on the Sentry issue. You don't move your workflow.
Pilot scope. Linking works for web apps (@bugcapsule/web with @sentry/browser). Flutter, Android and iOS apps can run both SDKs side by side, but their events aren't linked yet. The sentryCompanion() integration is included in Web SDK 0.4.0-beta.2.
What it does, and what it doesn't
| Does | Doesn't |
|---|---|
Tags each Sentry error event with the id of the Capsule recorded for the same thrown error (bugcapsule.capsule_id), or why none was recorded (bugcapsule.capture). | Import Sentry events as Capsules, or rebuild a replay from a stack trace. A Capsule exists only if BugCapsule was recording when the failure happened. |
| Writes the Sentry event id into the Capsule, so both sides name each other. Links are made from these ids only. | Match events and Capsules by message, stack or time. |
Keeps one link on the Sentry issue showing the latest outcome, valid/requested attempts and commit, e.g. BugCapsule#FIXED 3/3 valid @a1b2c3d4e5f6 · 1 Capsule, pointing to a BugCapsule page that needs sign-in. | Resolve, assign or comment on Sentry issues. One verified Capsule covers one recorded occurrence, not the whole issue. |
Keeps your beforeSend, integrations and error handling as they are; never throws into Sentry; never blocks your app. | Send recorded data (network bodies, state, inputs) to Sentry. |
1. Add the companion to your app
import * as Sentry from '@sentry/browser';
import { BugCapsule, sentryCompanion, networkIntegration, historyIntegration } from '@bugcapsule/web';
Sentry.init({
dsn: '<your Sentry DSN>',
integrations: [sentryCompanion()], // add to your existing integrations
});
await BugCapsule.init({
appVersion: '1.4.0',
appBuild: '52',
mode: 'qa',
monitoring: false, // Sentry stays your error monitor
gitSha: import.meta.env.VITE_BUGCAPSULE_GIT_SHA,
token: 'bcsdk.v1.…', // SDK token from the dashboard
integrations: [networkIntegration(), historyIntegration()],
});
- The order of the two
initcalls doesn't matter: one thrown error gives one Sentry event and at most one Capsule, whichever handler sees it first. monitoring: falseturns off BugCapsule's own error events, sessions and tracing headers; capture and replay keep working.- Errors you report with
Sentry.captureException(err)are linked too. CallBugCapsule.reportError(err)as well if you want the failure to reproduce in replay builds that don't load Sentry.
What the bugcapsule.capture tag means
| Value | Meaning |
|---|---|
scheduled | A Capsule was scheduled for this event; it uploads a moment later (or when the device is back online). |
sampled_out | A production session that sampling didn't select. Raise the sample rate in Capture Settings to record more. |
not_recording | Capture hadn't started (setup still running or failed). |
disabled | Capture off: enabled: false, the kill switch, autoCaptureOnFailure: false, or BugCapsule not initialized. |
limit / duplicate | The session already wrote its maximum, or already captured this failure. |
replaying | The event came from a replay run. |
not_a_failure | Ignored by ignoreError, or an error-level message rather than an exception. |
2. Connect Sentry in the dashboard
A project owner or admin does this once per project. For the pilot the connection uses a Sentry internal integration in your own organization:
- In Sentry: Settings → Developer Settings → Custom Integrations → Create New Integration → Internal Integration.
- Permissions: Project Read; Issue & Event Read & Write; Organization Read. Turn on Alert Rule Action.
- Save, then copy the token and the Client Secret.
- In BugCapsule: your project → Integrations → Sentry: choose the region (
sentry.io,us.sentry.ioorde.sentry.io), enter the organization, project and integration slugs, the token and the Client Secret, and connect. BugCapsule checks them with Sentry before saving and keeps them encrypted. - Copy the webhook URL BugCapsule shows into the integration's Webhook URL in Sentry.
- Create an alert rule for the Sentry project with the action Send a notification via your integration. (Organizations on Business or Enterprise plans can also subscribe the integration to
errorevents.)
The Integrations page shows the status (Connected, Needs attention, Access revoked), the last delivery, and any failed deliveries with a Retry button. A Sentry project can be connected to one BugCapsule project only.
3. Work from either side
- In Sentry: the issue shows a
BugCapsule#…link with the latest outcome. Open it (sign in to BugCapsule) to see each event and its Capsule. - In BugCapsule: a Capsule page shows In Sentry links to its event and issue. The Sentry issue page lists every event BugCapsule saw, with its Capsule, or No capsule recorded and the reason.
- Replay and verify as usual (bugcapsule CLI). Each recorded run updates the link on the Sentry issue:
REPRODUCED,STILL FAILING,INCONCLUSIVE,COULD NOT RUNorFIXED(only when every requested attempt ran validly and none reproduced).
Disconnecting
Disconnect from the Integrations page. BugCapsule deletes the stored token and secret, stops processing, and can first remove its links from Sentry issues. Then delete or rotate the integration's token in Sentry. Uninstalling the integration in Sentry also stops BugCapsule at once.
Troubleshooting
Sentry events show “No capsule recorded”
Check the event's bugcapsule.capture tag (table above). No tag at all means the app didn't run sentryCompanion().
The Capsule is linked but there's no link on the Sentry issue
The integration needs Issue & Event: Write, and the link is turned on in Integrations → Sentry (“Evidence on Sentry issues”). Failed deliveries are listed there with the reason.
A linked event says “Sentry hasn't confirmed the event yet”
Sentry is still processing it, or dropped it after the Capsule was linked (beforeSend returning null, sampling, inbound filters, rate limits). BugCapsule asks a few times, then marks it as not found.