endSession() recorded newtab.closed, drained the shared event buffer and submitted the newtab ping before it checked whether the session had ever been visible. The never-shown guard sat about 35 lines further down, so it only ever suppressed the session_duration bookkeeping: hidden preloaded newtabs still produced a full newtab_session_end ping carrying a newtab.closed event for a visit the user never saw. Observed steady state was three telemetry sessions for one visible newtab, two of them with is_preloaded: true and no visibility_event_rcvd_ts. Opening a browser window and closing it submits a newtab_session_end ping for the never-shown id. Hoist the guard above the recording so a session with no visibility_event_rcvd_ts is dropped without emitting anything, and dedent the timestamp rounding that used to live in the if branch. The buffer half matters as much as the event: because #eventBuffer is shared across sessions, these phantom preload session-ends were also the main thing draining it mid-session, which is why impressions and section impressions were being attributed to a ping describing a newtab that was never displayed. The preceding patch adds the shutdown flush that keeps those events from being lost now that preload teardown no longer sends them. test_endSession_no_ping_on_no_visibility_event already described this behaviour but only asserted over legacy telemetry events, so it passed throughout. It now also asserts that no newtab ping is submitted and that newtab.closed is not recorded. Claude-Session: https://claude.ai/code/session_015UDkPBx7WgtQ8EZ7LDV1X5
Bug 2060320 Comment 2 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
endSession() recorded newtab.closed, drained the shared event buffer and submitted the newtab ping before it checked whether the session had ever been visible. The never-shown guard sat about 35 lines further down, so it only ever suppressed the session_duration bookkeeping: hidden preloaded newtabs still produced a full newtab_session_end ping carrying a newtab.closed event for a visit the user never saw.