Bug Handler
A resilient, privacy‑first error reporting toolkit for Dart & Flutter applications.
It gives you:
- A central client to create, sanitize, deduplicate, rate‑limit, and send error reports.
- Built‑in context providers (app, device, network, UI, user) with caching and opt‑in heavy data.
- A flexible sanitization pipeline (masking by key and content, regex rewrites, depth/size pruning, allow/deny filters).
- Policy controls (severity gating, environment allow‑list, sampling, rate‑limit, dedupe window).
- Outbox persistence for offline scenarios and delivery retries.
- A composable reporter pipeline (console logging, share sheet; adapters stubs for Sentry/Crashlytics).
- Developer‑friendly guard helpers, a Result type, and a Flutter ErrorBoundary widget.
- A typed exception hierarchy that standardizes error shape and severity across domains.
Import package:bug_handler/bug_handler.dart for the reporting APIs. Flutter bindings, the error boundary and HTTP status helpers have separate imports.
AI coding-assistant support (agent plugin)
Package-specific support for Claude Code and OpenAI Codex is available as an installable agent plugin, maintained in this repository. This is developer tooling for coding agents - it is not a runtime feature of the Dart package, and it is not part of the pub.dev archive; it installs from this Git repository.
Supported surfaces: Claude Code (CLI, desktop, and other Claude Code surfaces that support plugins); Codex CLI v0.131.0+ and ChatGPT Work mode (Codex plugins are currently not available in the IDE extension, Chat mode, or mobile).
Claude Code
/plugin marketplace add omar-hanafy/bug_handler
/plugin install bug-handler@bug-handler
OpenAI Codex
codex plugin marketplace add omar-hanafy/bug_handler
codex plugin add bug-handler@bug-handler
Start a new session after installing (required by Codex; in Claude Code run /reload-plugins or restart).
The plugin covers setup, guards, custom reporters, privacy, diagnosis and code review. For upgrades, use migrate-legacy-api for 0.0.1-dev.x or migrate-dev6-to-dev7 for 1.0.0-dev.6.
Example prompts:
- "Wire bug_handler into this app - we already initialize Sentry in bootstrap."
- "Why do errors from staging never arrive in our backend?"
- "Migrate this project off the old BugReporter API."
The plugin contains instructions, reference material and illustrative fixtures. The current guidance covers dev.7, with migrations for older versions. Installation and troubleshooting.
Table of contents
-
Installation
-
Quick start
-
Core concepts
-
Flutter wiring
-
Guard helpers & Result
-
Exceptions overview
-
Transform hooks
-
Extending
-
Testing & tips
-
Troubleshooting
-
FAQ
-
License
Installation
Version 1.0.0-dev.7 requires Flutter 3.38.1 or later. Add it to your app’s pubspec.yaml.
dependencies:
bug_handler: ^1.0.0-dev.7
Import the main library in your app.
import 'package:bug_handler/bug_handler.dart';
Upgrading from dev.6. Native reporters and provider plugin injections keep
their existing APIs. For a shared browser/native reporter, replace a file used
for upload with the attachment reporter. For browser tests with
injected plugins, switch to provider readers. Browser share
tests that intercepted SharePlatform.instance should now exercise Web Share
or the download. Check exception equality if your app
uses exceptions as state values or map keys.
Quick start
Initialize once during app bootstrap and run your app under the provided bindings:
import 'package:bug_handler/bug_handler.dart';
import 'package:bug_handler/flutter/bindings.dart';
import 'package:flutter/foundation.dart' show kReleaseMode;
import 'app.dart' show MyApp;