sentry_dart_frog 0.0.1 icon indicating copy to clipboard operation
sentry_dart_frog: ^0.0.1 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);
}
1
likes
130
pub points
0%
popularity

Publisher

verified publisher iconuekoetter.dev

Sentry integration for dart_frog. Capture errors and trace performance

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

dart_frog, sentry

More

Packages that depend on sentry_dart_frog