getUserContext static method
Future<SelfDescribing?>
getUserContext(
)
Implementation
static Future<SelfDescribing?> getUserContext() async {
final userJson = await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkVerifiedUserKey)!);
var user = userJson != null ? jsonDecode(userJson) : null;
var phone =
user != null ? user!['phone']?.replaceAll(RegExp(r'^\+91'), '') : null;
final numericPhoneNumber = int.tryParse(phone ?? '');
if (numericPhoneNumber != null ||
(user != null && user?['email'] != null)) {
final schemas = cdnConfigInstance.getSnowplowSchema();
final userSchema = (schemas is Map<String, String>)
? (schemas['user'] ?? 'user/jsonschema/1-0-0')
: 'user/jsonschema/1-0-0';
return _createContext(
userSchema,
{
'phone': numericPhoneNumber?.toString() ?? '',
'email': user?['email'] ?? '',
},
);
}
return null;
}