From 06ee489cde00c8c256e64a3ab5e4cd8adecb289e Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 16 Nov 2023 14:22:30 +0100 Subject: [PATCH] feat: add logout method --- .../interfaces/error_tracking_service.dart | 23 ++++++++++++------- .../services/error_tracking_service.dart | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/common/interfaces/error_tracking_service.dart b/lib/common/interfaces/error_tracking_service.dart index 7ca1dfb..42c5994 100644 --- a/lib/common/interfaces/error_tracking_service.dart +++ b/lib/common/interfaces/error_tracking_service.dart @@ -7,18 +7,21 @@ import 'package:sentry_flutter/sentry_flutter.dart'; class ErrorTrackingService implements IErrorTrackingService { @override Future setUser(ErrorTrackingUser user) async { - await Sentry.configureScope( - (scope) => scope.setUser( - SentryUser( - email: user.email, - id: user.id, - name: user.name, - username: user.username, - ), + await _setSentryUser( + SentryUser( + email: user.email, + id: user.id, + name: user.name, + username: user.username, ), ); } + @override + Future logout() async { + await _setSentryUser(null); + } + @override Future setTag(String key, String value) async { await Sentry.configureScope((scope) => scope.setTag(key, value)); @@ -32,4 +35,8 @@ class ErrorTrackingService implements IErrorTrackingService { ), ); } + + Future _setSentryUser(SentryUser? user) async { + await Sentry.configureScope((scope) => scope.setUser(user)); + } } diff --git a/lib/common/services/error_tracking_service.dart b/lib/common/services/error_tracking_service.dart index 74cdab9..0941b84 100644 --- a/lib/common/services/error_tracking_service.dart +++ b/lib/common/services/error_tracking_service.dart @@ -1,5 +1,6 @@ abstract class IErrorTrackingService { Future setUser(ErrorTrackingUser user); + Future logout(); Future setTag(String key, String value); Future setTags(Map tags); }