BugCapsule class abstract final

Entry point of the BugCapsule SDK.

void main() => BugCapsule.init(
      config: const BugCapsuleConfig(token: 'bcsdk.v1.…'),
      appRunner: () => runApp(const MyApp()),
    );

Replay gets more complete with each integration the app adds: integrations: [BugCapsuleDio(...), BugCapsuleGoRouter(), BugCapsuleBloc(...)]. status tells what is connected and what is still missing.

Call init first in main, before WidgetsFlutterBinding.ensureInitialized, so the binding is created inside BugCapsule's zone and clock.now() is controllable during replay.

BugCapsule never stops the app from starting: if storage, an integration's setup or anything else in capture setup fails, the app runs without capture and the reason is printed with debugPrint.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

activeSpan → BugCapsuleSpan?
The span of the current zone (startSpan), else the transaction bound to the scope (the current screen), if open.
no setter
debugOverrides ↔ BugCapsuleTestOverrides?
getter/setter pair
isInitialized → bool
no setter
isRecording → bool
no setter
isReplaying → bool
no setter
mode → CaptureMode?
no setter
overlayEnabled → bool
no setter
random → Random
Seeded per session and restored in replay. Use it for randomness that affects behaviour you want reproducible.
no setter
session → BugCapsuleSession?
no setter
status → BugCapsuleStatus
Connection and instrumentation, for setup checks and support: whether the token works, whether the backend accepted the config fetch and the first data, and which replay integrations are still missing. Before init the state is notConfigured.
no setter

Static Methods

action(String id, VoidCallback callback) → VoidCallback
Wraps a UI callback as a named semantic action: records it, and lets semantic replay invoke it by id.
actionWithPayload(String id, void callback(Map<String, Object?> payload)) → void Function(Map<String, Object?> payload)
Like action with a JSON payload passed to the handler.
addBreadcrumb(Breadcrumb breadcrumb) → void
addIsolateErrorListener(Isolate isolate) → void
Sends uncaught errors of isolate (one the app spawned) as events.
capture({String? note}) → Future<CaptureResult?>
Writes a capsule now (QA "capture" button). Uses the latest failure in the window as the assertion when there is one.
captureException(Object error, {StackTrace? stackTrace, EventLevel? level, Map<String, String>? tags, Map<String, Object?>? extra, List<String>? fingerprint, Map<String, Object?>? contexts}) → String?
Sends error as an error event (handled, level error unless given) with the current scope. Returns the event id, or null when monitoring is off or the event was sampled out.
captureFeedback({required String message, String? name, String? email, String? eventId, String? url, Map<String, String>? tags, bool? captureCapsule}) → Future<String?>
Sends user feedback (monitoring-v1 §9), linked to eventId when given. With captureCapsule (default: MonitoringOptions.captureCapsuleWithFeedback, true in QA mode) a capsule is written too and linked by capsuleId. Returns the feedback id, or null when monitoring is off or message is empty.
captureMessage(String message, {EventLevel level = EventLevel.info, Map<String, String>? tags}) → String?
Sends a message event (with the current stack when attachStacktrace).
check(String assertionId, bool condition, [String message = '']) → void
Raises assertionId when condition is false.
clearBreadcrumbs() → void
close() → Future<void>
Ends the session, uploads queued envelopes and stops monitoring.
configureScope(void fn(Scope scope)) → void
continueTrace(String? traceparent, String? baggage) → void
Continues an incoming trace: the next root transaction uses its trace id, parent span and sampling decision.
endSession() → void
fail(String assertionId, [String message = '']) → void
Raises a named failure assertion. Replay is judged against assertionId.
flush([Duration timeout = const Duration(seconds: 10)]) → Future<bool>
Uploads queued monitoring envelopes. True when the queue is empty.
flushUploads() → Future<void>
Uploads queued capsules now, if the remote config allows it.
getBaggage() → String?
getTraceparent() → String?
traceparent for a request made by a custom client, or null when no span is active.
init({required BugCapsuleConfig config, List<BugCapsuleIntegration> integrations = const [], required FutureOr<void> appRunner()}) → Future<void>
lastEventId() → String?
Id of the last error event that was sent (not sampled out).
log(String message, {String level = 'info'}) → void
refreshRemoteConfig() → Future<void>
Fetches the remote capture config now (it is otherwise refreshed after its TTL and when the app resumes). The returned future completes with a config fetched after this call, also when a fetch was already running (such as the one init starts).
resetForTest() → Future<void>
runZonedGuarded<R>(R body(), {void onError(Object error, StackTrace stack)?}) → R?
runZonedGuarded that sends uncaught zone errors as uncaught events (and treats them as failures), then calls onError:
savedCaptures() → Future<List<File>>
setContext(String name, Object? value) → void
setExtra(String key, Object? value) → void
setExtras(Map<String, Object?> extras) → void
setFingerprint(List<String>? fingerprint) → void
setLevel(EventLevel? level) → void
setTag(String key, String value) → void
setTags(Map<String, String> tags) → void
setUser(MonitoringUser? user) → void
startSession() → void
Sessions are automatic; these are for apps that manage them.
startSpan<R>(String name, String op, FutureOr<R> fn(BugCapsuleSpan span)) → FutureOr<R>
Runs fn inside a span that is active for its zone (children, HTTP spans and error events attach to it) and finishes it when fn completes (status internal_error if it throws). A child of the active span, else a new transaction.
startTransaction(String name, String op, {bool bindToScope = false}) → BugCapsuleTransaction
Starts a root transaction (a new trace, or the one passed to continueTrace). With bindToScope it becomes the parent of spans started outside startSpan (e.g. HTTP spans). Finish it to send it.
suppressPointer(int pointer) → void
trackText(String id, TextEditingController controller, {bool sensitive = false}) → void
Records edits of controller under id and restores them in replay. Values are redacted when sensitive is true (use it for any obscured field) or the id looks sensitive (password, otp, ...); credentials found inside other values are scrubbed.
untrackText(String id, TextEditingController controller) → void
withScope<R>(R fn(Scope scope)) → R
Runs fn with a copy of the current scope; changes to it apply only to what is captured inside fn (including its async continuations).