how to track if a player has left the server

Is there any way to track whether a player is online on the server or whether he has left the game using datapack?

Continue to help post