Seamless integration between Sentry and GetX framework for Flutter. Provides automatic error tracking, route observation, and controller lifecycle monitoring.
- 🔍 Automatic Route Tracking - Track page navigation automatically with
SentryRouteObserver - 🎮 Controller Lifecycle Monitoring - Automatically track GetX controller creation and disposal
- 🐛 Exception Capturing - Capture and send exceptions to Sentry with rich context
- 📝 Custom Messages - Send custom messages with different severity levels
- 🍞 Breadcrumb Tracking - Track user actions, HTTP requests, and navigation events
- 📄 Page Tracking - Manual page tracking with metadata support
Add getx_sentry to your pubspec.yaml:
dependencies:
getx_sentry: ^1.0.0Then run:
flutter pub getimport 'package:flutter/material.dart';
import 'package:getx_sentry/getx_sentry.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SentryFlutter.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.environment = 'production';
options.tracesSampleRate = 1.0;
},
appRunner: () => runApp(const MyApp()),
);
}class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
// Add route observers for automatic navigation tracking
navigatorObservers: [
SentryNavigatorObserver(),
SentryRouteObserver(),
],
initialBinding: AppBindings(),
home: HomeScreen(),
);
}
}class AppBindings extends Bindings {
@override
void dependencies() {
// Register SentryService as a permanent service
Get.put<SentryService>(SentryService(), permanent: true);
// Initialize controller lifecycle tracking
SentryGetXControllerDetector.initialize();
}
}try {
// Your code that might throw
} catch (e, stackTrace) {
await SentryService.instance?.captureException(
e,
stackTrace: stackTrace,
hint: 'Error occurred during data fetch',
extra: {'user_action': 'fetch_data'},
tags: [{'key': 'module', 'value': 'api'}],
);
}await SentryService.instance?.captureMessage(
'User completed checkout',
level: SentryLevel.info,
extra: {'order_id': '12345'},
);SentryService.instance?.addBreadcrumb(
type: SentryEventType.userInteraction,
message: 'Button tapped',
data: {'button_id': 'submit'},
);SentryService.instance?.setCurrentPage(
'ProductDetailsScreen',
metadata: {'product_id': '123'},
);| Type | Description |
|---|---|
SentryEventType.navigation |
Route/page transitions |
SentryEventType.userInteraction |
User actions (taps, gestures) |
SentryEventType.http |
API requests |
SentryEventType.error |
Error events |
SentryEventType.warning |
Warning events |
SentryEventType.info |
Informational events |
| Method | Description |
|---|---|
captureException() |
Capture and send exceptions to Sentry |
captureMessage() |
Send custom messages to Sentry |
addBreadcrumb() |
Add breadcrumbs for event tracking |
setCurrentPage() |
Track page navigation manually |
Automatically tracks GetX route changes and sends them as breadcrumbs to Sentry.
Automatically detects and logs GetX controller lifecycle events (init, close).
// Access package version information
print(GetxSentryInfo.version); // "1.0.0"
print(GetxSentryInfo.formattedInfo); // Full version string- Flutter SDK
- Dart SDK: ^3.10.8
- get: ^4.6.5
- sentry_flutter: ^9.6.0
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you find a bug or have a feature request, please open an issue on GitHub.