feat: implement Learning Tracer (heartbeat duration tracking) for LPK Audit

This commit is contained in:
2026-01-23 19:06:32 +07:00
parent 8a61cda3e4
commit 6caa0e88dd
5 changed files with 85 additions and 0 deletions

View File

@@ -148,6 +148,22 @@ export default function Player({ course, currentLesson, progress, auth }: Player
const [sidebarOpen, setSidebarOpen] = useState(true);
const [isPlaying, setIsPlaying] = useState<string | null>(null);
// Learning Tracer - Heartbeat every 60 seconds
useEffect(() => {
const interval = setInterval(() => {
// @ts-ignore
router.post(route('lessons.heartbeat', { lesson: currentLesson.id }), {}, {
preserveScroll: true,
preserveState: true,
only: [], // Prevent any data reload to keep it "silent"
// @ts-ignore
onFinish: () => {}
});
}, 60000);
return () => clearInterval(interval);
}, [currentLesson.id]);
const handleComplete = () => {
// @ts-ignore
router.post(route('lessons.complete', { lesson: currentLesson.id }));