Session reports

Build session-level report data from monitoring-session metadata and foreground-event records.

Report construction


source

build_session_report_data

def build_session_report_data(
    session, events
):

Return session metadata, summary metrics, and event breakdowns as a report dictionary.

Session and event preparation

Event aggregation

  • _clean_events derives app_name from window_title rather than using the existing event app field. Confirm that this is intentional.
  • A title without " - " becomes the complete app_name, while its clean_title becomes "Unknown". Titles containing several separators retain only the final two components.
  • _clean_events assumes every event has non-null, parseable start_time, end_time, and string window_title values. Confirm that the database layer guarantees these conditions.
  • _session_data assumes both session timestamps are present and parseable. It cannot directly process an open session with end_time=None.
  • Session duration is calculated from the session timestamps, while summary duration is the sum of event durations. These values can differ when events contain gaps or overlaps.
  • app_switch_count is calculated after idle rows are removed. Consequently, App A → Idle → App A is treated as no application switch.
  • The current title breakdown returns title duration but not the requested percent within the application. It also does not return an explicit title count or single top-title field.
  • A non-positive top_n_apps or top_n_titles value means “include all,” not “include none.” Confirm that this matches the intended configuration semantics.
  • The configured top-app and top-title limits are captured as default arguments when the module is imported. Runtime changes to those configuration attributes will not change the defaults until the module is reloaded.