Install the sentry Flutter SDK:
flutter pub add sentry_flutter
Initialize the SDK in lib/main.dart:
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
void main() {
SentryFlutter.init(
(options) => options
..dsn = 'YOUR_DSN'
..tracesSampleRate = 0.01 // 1% of transactions
..enableAutoSessionTracking = false, // GlitchTip does not support sessions
appRunner: () => runApp(MyApp()),
);
}
Verify your setup:
try {
throw Exception('Test GlitchTip error!');
} catch (exception, stackTrace) {
Sentry.captureException(exception, stackTrace: stackTrace);
}
You can also set DSN and other options via environment variables with --dart-define:
flutter run --dart-define=SENTRY_DSN='YOUR_DSN'
Upload Dart symbol maps for readable stack traces using the GlitchTip CLI:
glitchtip-cli dart-symbol-map upload ./build/app.android-arm64.symbols ./build/app.android-arm64 --org my-org --project my-project
tracesSampleRate to a low value in production to save disk space.