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