Flutter errors, logs, and breadcrumbs
FlutterError, platform, zone, and ErrorWidget capture, plus logs, breadcrumbs, and setUser on talaria_flutter.
TalariaFlutter.init installs FlutterError.onError and PlatformDispatcher.onError unless you pass installHooks: false. runZonedApp also wraps the zone and installs ErrorWidget.builder.
Manual init
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await TalariaFlutter.init(TalariaOptions(
dsn: 'https://ingest.newtalaria.com',
apiKey: const String.fromEnvironment('TALARIA_API_KEY'),
release: const String.fromEnvironment('APP_RELEASE'),
minLevel: SeverityLevel.warning,
));
ErrorWidget.builder = talariaErrorWidgetBuilder();
runApp(MyApp(
navigatorObservers: [TalariaNavigatorObserver()],
));
}What each hook captures
FlutterError.onErrorcaptures framework assertions and build or layout failures that Flutter reports.PlatformDispatcher.onErrorcaptures uncaught platform and async errors that miss the framework.- The zone from
runZonedAppcaptures errors thrown outside the framework binding. talariaErrorWidgetBuildercaptures a widget build failure once per error (error_widget).runZonedAppinstalls this for you.
TalariaFlutter.isWidgetBuildError is the predicate that keeps a broken build from sending the same widget failure on every frame.
Manual capture
Hooks do not replace try / catch around recoverable work.
try {
await riskyOperation();
} catch (error, stackTrace) {
await Talaria.captureException(
error,
stackTrace: stackTrace,
context: CaptureContext(tags: {'screen': 'checkout'}),
);
rethrow;
}Logs
Logs are the talaria methods this package re-exports.
final log = Talaria.logger(name: 'checkout', tags: {'screen': 'checkout'});
await log.warning('Payment method missing');
await Talaria.captureMessage(
'Checkout failed closed',
level: SeverityLevel.error,
);Breadcrumbs
Navigation crumbs come from TalariaNavigatorObserver. Add your own before a step that might fail:
Talaria.addBreadcrumb(Breadcrumb(
type: 'user',
category: 'checkout',
message: 'Opened payment step',
level: 'info',
));The lifecycle observer updates the app.state tag (resumed, paused, detached).
Identity and context
Talaria.setUser('user_42');
Talaria.getClient()?.setTags({'area': 'billing'});
Talaria.getClient()?.setExtra({'plan': 'pro'});Init sets platform: flutter and a flutter: true tag. Runtime extras include locale, OS, and on web the renderer and user agent. Set release in TalariaOptions. Fingerprints are computed on the server.