<commit_before>defmodule RemoteRetro.PresenceUtils do
  @moduledoc """
  Helpers for retro user presence.
  """
  alias RemoteRetro.{Presence, User}
  alias Phoenix.Token

  def track_timestamped(%{assigns: assigns} = socket) do
    {:ok, user} = Token.verify(socket, "user", assigns.user_token)
    user = %User{user | online_at: :os.system_time}

    Presence.track(socket, assigns.user_token, user)
  end
end<commit_msg>Only track presences in cases<commit_after>defmodule RemoteRetro.PresenceUtils do
  @moduledoc """
  Helpers for retro user presence.
  """
  alias RemoteRetro.{Presence, User}
  alias Phoenix.Token

  def track_timestamped(%{assigns: assigns} = socket) do
    case Token.verify(socket, "user", assigns.user_token) do
      {:ok, user} ->
        user = %User{user | online_at: :os.system_time}
        Presence.track(socket, assigns.user_token, user)
      {:error, :invalid} ->
        IO.puts "User with stale tab open"
    end
  end
end
{'fraction_non_alphanumeric': 0.11734164070612668, 'fraction_numerical': 0.0, 'mean_word_length': 3.7960199004975124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4759059', 'n_tokens_mistral': 328, 'n_tokens_neox': 315, 'n_words': 80}