import { appBasePath } from "@agent-native/core/client/api-path"; import { useEffect, useRef } from "react"; import { clampCompletionPct } from "../../shared/view-analytics"; const SESSION_KEY = "clips-view-session-id"; function getSessionId(): string { if (typeof window === "undefined") return "server"; try { let id = localStorage.getItem(SESSION_KEY); if (!id) { id = "s-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8); localStorage.setItem(SESSION_KEY, id); } return id; } catch { return "s-" + Math.random().toString(36).slice(2, 8); } } function createViewSessionId(recordingId: string): string { return [ "v", recordingId, Date.now().toString(36), Math.random().toString(36).slice(2, 8), ].join("-"); } export interface UseViewTrackingOpts { recordingId: string; /** * The live `