From f3293bb12321dcbc7bb478e06870211d76d214c7 Mon Sep 17 00:00:00 2001 From: James Elgar Date: Sun, 13 Oct 2024 12:37:58 +0100 Subject: [PATCH] Capture login exceptions in sentry (#337) --- lib/services/auth.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/services/auth.dart b/lib/services/auth.dart index 4759f544..beec34a4 100644 --- a/lib/services/auth.dart +++ b/lib/services/auth.dart @@ -11,6 +11,7 @@ import 'package:nowu/locator.dart'; import 'package:nowu/services/analytics.dart'; import 'package:nowu/services/storage.dart'; import 'package:nowu/utils/let.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sign_in_with_apple/sign_in_with_apple.dart'; import 'package:supabase_flutter/supabase_flutter.dart' hide User; import 'package:supabase_flutter/supabase_flutter.dart'; @@ -105,8 +106,14 @@ class AuthenticationService { } Future signInWithOAuth(AuthProvider provider) async { - final response = await _signInWithOAuth(provider); - return response?.let(OAuthLoginResult.fromAuthResponse); + try { + final response = await _signInWithOAuth(provider); + return response?.let(OAuthLoginResult.fromAuthResponse); + } catch (exception, stackTrace) { + _logger.warning('Login with oauth failed provider=$provider', exception); + await Sentry.captureException(exception, stackTrace: stackTrace); + throw exception; + } } Future _signInWithOAuth(AuthProvider provider) {