Add glitchtip for centralized error logging

This commit is contained in:
2026-07-30 02:32:30 +02:00
parent 498ad68e1c
commit c210f80f27
15 changed files with 416 additions and 193 deletions
+37 -18
View File
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import '../models/product.dart';
import '../services/product_service.dart';
@@ -13,35 +14,53 @@ class InventoryViewModel extends ChangeNotifier {
List<Product> get products => _products;
Future<void> load() async {
_products = await productService.getProducts();
notifyListeners();
try {
_products = await productService.getProducts();
notifyListeners();
} catch (e, stack) {
debugPrint('InventoryViewModel: load error: $e');
Sentry.captureException(e, stackTrace: stack);
rethrow;
}
}
Future<void> decreaseStock(String productId, int amount) async {
await productService.decreaseStock(productId, amount);
try {
await productService.decreaseStock(productId, amount);
final index = _products.indexWhere((product) => product.id == productId);
final index = _products.indexWhere((product) => product.id == productId);
if (index != -1) {
_products[index] = _products[index].copyWith(
stockQuantity: _products[index].stockQuantity - amount,
);
if (index != -1) {
_products[index] = _products[index].copyWith(
stockQuantity: _products[index].stockQuantity - amount,
);
}
notifyListeners();
} catch (e, stack) {
debugPrint('InventoryViewModel: decreaseStock error: $e');
Sentry.captureException(e, stackTrace: stack);
rethrow;
}
notifyListeners();
}
Future<void> increaseStock(String productId, int amount) async {
await productService.increaseStock(productId, amount);
try {
await productService.increaseStock(productId, amount);
final index = _products.indexWhere((product) => product.id == productId);
final index = _products.indexWhere((product) => product.id == productId);
if (index != -1) {
_products[index] = _products[index].copyWith(
stockQuantity: _products[index].stockQuantity + amount,
);
if (index != -1) {
_products[index] = _products[index].copyWith(
stockQuantity: _products[index].stockQuantity + amount,
);
}
notifyListeners();
} catch (e, stack) {
debugPrint('InventoryViewModel: increaseStock error: $e');
Sentry.captureException(e, stackTrace: stack);
rethrow;
}
notifyListeners();
}
}