File size: 744 Bytes
94193b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /**
* Once-per-page-load guard for the `session_start` event.
*
* In server mode the telemetry bootstrap (PageWrapper) remounts on every route
* navigation, but a session must be counted once per page load, not once per
* navigation. This module-level flag survives client-side navigations, so
* `markSessionStartedOnce()` returns true exactly once and false thereafter.
*/
let started = false;
/** Returns true the first time it is called per module lifetime, false after. */
export function markSessionStartedOnce(): boolean {
if (started) return false;
started = true;
return true;
}
/** Test-only: reset the guard so each test case starts fresh. */
export function __resetSessionGuardForTests(): void {
started = false;
}
|