Calculating any session length statistic requires us to be able to determine how long sessions are (as well as deciding what counts as a session).
Defining a session is one question, but another question is figuring out how to technically measure it. Below are several vastly different approaches, differing in complexity, privacy, and feasibility:
Heartbeat approach (mentioned here and currently used here)
Client pings the server (sending an event) at a regular interval, the last ping is approximately when the session ended.
"On unload" approach:
Client keeps track of how long the session has lasted and sends a time duration as an event on page unload / app close.
"On load/unload" approach:
Client sends event containing an identifier and a "start" timestamp at the start of the session. Then another event with the same identifier and a "stop" timestamp on unload/close, offloading timestamp differencing calculation to some server-side ETL process.
Implicit approach:
With enough features/experiences having analytics instrumentation attached and an identifier linking them all to the same session (the behavior of the Modern Event Platform Client Libraries), we do not need instrumentation solely for session lengths and can simply have an ETL process that joins multiple tables together by session ID, finds the first event sent in a session, finds the last event sent in a session, and differences their timestamps.