getSnowplowUserId method

String? getSnowplowUserId()

Implementation

String? getSnowplowUserId() {
  final userId = _cache[_userIdKey];
  final timestamp = _cache[_timestampKey];

  if (userId == null || timestamp == null) return null;

  final storedTime = DateTime.tryParse(timestamp);
  if (storedTime == null) return null;

  if (DateTime.now().difference(storedTime).inHours > 24) {
    return null;
  }

  return userId;
}