Skip to content

Commit

Permalink
feat: add logout method
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaugomez committed Nov 16, 2023
1 parent e3eb375 commit 06ee489
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/common/interfaces/error_tracking_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ import 'package:sentry_flutter/sentry_flutter.dart';
class ErrorTrackingService implements IErrorTrackingService {
@override
Future<void> 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<void> logout() async {
await _setSentryUser(null);
}

@override
Future<void> setTag(String key, String value) async {
await Sentry.configureScope((scope) => scope.setTag(key, value));
Expand All @@ -32,4 +35,8 @@ class ErrorTrackingService implements IErrorTrackingService {
),
);
}

Future<void> _setSentryUser(SentryUser? user) async {
await Sentry.configureScope((scope) => scope.setUser(user));
}
}
1 change: 1 addition & 0 deletions lib/common/services/error_tracking_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
abstract class IErrorTrackingService {
Future<void> setUser(ErrorTrackingUser user);
Future<void> logout();
Future<void> setTag(String key, String value);
Future<void> setTags(Map<String, String> tags);
}
Expand Down

0 comments on commit 06ee489

Please sign in to comment.