Set anonymized identifier for crashes

This commit is contained in:
vishnukvmd 2021-07-24 21:07:57 +05:30
parent bdb344f040
commit d29bd9a046
4 changed files with 14 additions and 5 deletions

View file

@ -24,6 +24,7 @@ import 'package:photos/services/sync_service.dart';
import 'package:photos/utils/crypto_util.dart'; import 'package:photos/utils/crypto_util.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:super_logging/super_logging.dart'; import 'package:super_logging/super_logging.dart';
import 'package:uuid/uuid.dart';
class Configuration { class Configuration {
Configuration._privateConstructor(); Configuration._privateConstructor();
@ -51,6 +52,7 @@ class Configuration {
"has_migrated_secure_storage_to_first_unlock"; "has_migrated_secure_storage_to_first_unlock";
static const hasSelectedAllFoldersForBackupKey = static const hasSelectedAllFoldersForBackupKey =
"has_selected_all_folders_for_backup"; "has_selected_all_folders_for_backup";
static const anonymousUserIDKey = "anonymous_user_id";
final kTempFolderDeletionTimeBuffer = Duration(days: 1).inMicroseconds; final kTempFolderDeletionTimeBuffer = Duration(days: 1).inMicroseconds;
@ -105,8 +107,8 @@ class Configuration {
iOptions: _secureStorageOptionsIOS, iOptions: _secureStorageOptionsIOS,
); );
await _migrateSecurityStorageToFirstUnlock(); await _migrateSecurityStorageToFirstUnlock();
SuperLogging.setUserID(getUserID());
} }
SuperLogging.setUserID(await _getOrCreateAnonymousUserID());
} }
Future<void> logout() async { Future<void> logout() async {
@ -514,4 +516,11 @@ class Configuration {
hasMigratedSecureStorageToFirstUnlockKey, true); hasMigratedSecureStorageToFirstUnlockKey, true);
} }
} }
Future<String> _getOrCreateAnonymousUserID() async {
if (!_preferences.containsKey(anonymousUserIDKey)) {
await _preferences.setString(anonymousUserIDKey, Uuid().v4());
}
return _preferences.getString(anonymousUserIDKey);
}
} }

View file

@ -1011,7 +1011,7 @@ packages:
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
uuid: uuid:
dependency: transitive dependency: "direct main"
description: description:
name: uuid name: uuid
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"

View file

@ -88,6 +88,7 @@ dependencies:
syncfusion_flutter_sliders: ^19.1.67-beta syncfusion_flutter_sliders: ^19.1.67-beta
uni_links: ^0.5.1 uni_links: ^0.5.1
url_launcher: ^6.0.3 url_launcher: ^6.0.3
uuid: ^3.0.4
video_player: ^2.0.0 video_player: ^2.0.0
visibility_detector: ^0.2.0 visibility_detector: ^0.2.0
wallpaper_manager_flutter: ^0.0.2 wallpaper_manager_flutter: ^0.0.2

View file

@ -182,9 +182,8 @@ class SuperLogging {
} }
} }
static void setUserID(int userID) { static void setUserID(String userID) {
Sentry.configureScope( Sentry.configureScope((scope) => scope.user = SentryUser(id: userID));
(scope) => scope.user = SentryUser(id: userID.toString()));
} }
static Future<void> _sendErrorToSentry(Object error, StackTrace stack) async { static Future<void> _sendErrorToSentry(Object error, StackTrace stack) async {