sentry_dart_frog 0.2.2 copy "sentry_dart_frog: ^0.2.2" to clipboard
sentry_dart_frog: ^0.2.2 copied to clipboard

Sentry integration for dart_frog. Capture errors and trace performance

example/sentry_dart_frog_example.dart

import 'package:sentry_dart_frog/sentry_dart_frog.dart';

import 'dart:async';
import 'dart:io';

import 'package:dart_frog/dart_frog.dart';
import 'package:sentry/sentry.dart';

// main.dart
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
  await Sentry.init((options) {
    options
      ..dsn = '<your_dsn_here>'
      ..tracesSampleRate = 1
      ..addDartFrogInAppExcludes();
  });
  return await runZonedGuarded(() {
    return serve(handler, ip, port);
  }, (error, stack) {
    final mechanism = Mechanism(type: 'runZonedGuarded', handled: true);
    final throwableMechanism = ThrowableMechanism(mechanism, error);

    final event = SentryEvent(
      throwable: throwableMechanism,
      level: SentryLevel.fatal,
    );

    Sentry.captureEvent(event, stackTrace: stack);
  })!;
}

// _middleware.dart
Handler middleware(Handler handler) {
  return handler
      // add all Sentry middleware
      .use(sentryMiddleware);
}
3
likes
160
pub points
61%
popularity

Publisher

verified publisheruekoetter.dev

Sentry integration for dart_frog. Capture errors and trace performance

Repository (GitHub)
View/report issues

Topics

#server #http #middleware #error #dart-frog

Documentation

API reference

License

MIT (license)

Dependencies

dart_frog, sentry

More

Packages that depend on sentry_dart_frog