Skip to content

Commit

Permalink
feat: add logger in riverpod (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
YassinNouh21 committed Aug 14, 2024
1 parent 1d6c06a commit 9d497fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:mawaqit/src/helpers/AppRouter.dart';
import 'package:mawaqit/src/helpers/ConnectivityService.dart';
import 'package:mawaqit/src/helpers/CrashlyticsWrapper.dart';
import 'package:mawaqit/src/helpers/riverpod_logger.dart';
import 'package:mawaqit/src/helpers/riverpod_sentry_provider_observer.dart';
import 'package:mawaqit/src/pages/SplashScreen.dart';
import 'package:mawaqit/src/services/audio_manager.dart';
import 'package:mawaqit/src/services/FeatureManager.dart';
Expand Down Expand Up @@ -48,7 +49,10 @@ Future<void> main() async {
runApp(
ProviderScope(
child: MyApp(),
observers: [RiverpodLogger()],
observers: [
RiverpodLogger(),
RiverpodSentryProviderObserver(),
],
),
);
},
Expand Down
15 changes: 15 additions & 0 deletions lib/src/helpers/riverpod_sentry_provider_observer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

class RiverpodSentryProviderObserver extends ProviderObserver {
@override
void providerDidFail(
ProviderBase<Object?> provider,
Object error,
StackTrace stackTrace,
ProviderContainer container,
) {
Sentry.captureException(error, stackTrace: stackTrace);
super.providerDidFail(provider, error, stackTrace, container);
}
}

0 comments on commit 9d497fe

Please sign in to comment.