Bugwatchbugwatch

SDK · Dart

Dart / Flutter

Official Bugwatch SDK for Dart and Flutter. One dependency (package:http). Events are sent asynchronously with an internal queue, so a slow or down Bugwatch server never stalls your application. Stack traces are captured with file, line and column.

Install

Bash
dart pub add bugwatch_sdk

The package is published on pub.dev. For Flutter projects, run flutter pub add bugwatch_sdk.

Flutter quickstart

Dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:bugwatch_sdk/bugwatch_sdk.dart';

void main() {
  Bugwatch.init(
    'https://bw-YOUR_KEY@bugwatch-api.loadmindx.com/api/1',
    environment: 'production',
    release: '1.0.0',
  );
  // Auto-capture all uncaught Flutter zone errors:
  runZonedGuarded(() => runApp(MyApp()), Bugwatch.captureException);
}

runZonedGuarded captures every uncaught error in the Flutter zone — no try/catch needed.

Pure Dart

Dart
Bugwatch.init('https://bw-YOUR_KEY@bugwatch-api.loadmindx.com/api/1');

try {
  riskyOperation();
} catch (e, st) {
  Bugwatch.captureException(e, st);
}

Bugwatch.captureMessage('Payment confirmed', level: 'info');

await Bugwatch.flush(); // wait for async sends (short-lived scripts)

API

APIDescription
init(dsn, {environment, release, sampleRate, debug, allowHttp})Parse the DSN, validate HTTPS (unless allowHttp).
captureException(error, [stackTrace]) -> id?Capture an exception with its stack trace.
captureMessage(msg, {level}) -> id?Capture a message: debug, info, warning, error or fatal.
setTag(k, v)Set a tag on subsequent events.
setUser(id, {extra})Set user context (PII stripped).
addBreadcrumb({category, message})Append to the trail (max 100).
clearScope()Clear tags, user and breadcrumbs.
flush()Wait for pending async sends. Call it before the process exits.