Programming Phoenix LiveView:

Hi! Thanks for submitting your question. It does in fact look like there is a mistake in that code! The correct case statement should read like this:

case Presence.get_by_key("user_activity", product.name) do
  [] ->
    Presence.track(
      pid,
      "user_activity",
      product.name, %{users: [%{email: user.email}]}
    )

  %{metas: [%{users: active_users_for_product}]} ->
    Presence.update(pid, "user_activity", product.name, %{
      users: [active_users_for_product | %{email: user.email}]
    })
end

You’ll find that updated in the next Beta release. In the meantime, you can copy in the correction from this comment.