Programming Phoenix LiveView:

socket is being accessed in the function body, hence the need to include it in the function head.
Current:
def maybe_track_user(

  •     product,*
    
  •     %{assigns: %{live_action: :show, user_token: user_token}}*
    
  •     ) do*
    
  •            if connected?(socket) do*
    
  •            user = Accounts.get_user_by_session_token(user_token)*
    
  •            # do tracking here!*
    
  • end*

Expected:
def maybe_track_user(

  •  product,*
    
  •  %{assigns: %{live_action: :show, user_token: user_token}} **= socket***
    
  •  ) do*
    
  •          if connected?(socket) do*
    
  •          user = Accounts.get_user_by_session_token(user_token)*
    
  •         # do tracking here!*
    

end

Title: Programming Phoenix LiveView: B3.0: Include “=socket” in function header (page 255)
Example: Programming Flutter - ‘pub get’ command not working (page 15)

Please also add the book’s tag if it has not already present, thanks!