From d36e61c4f705545229e81e276590d577f36e9fdc Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Tue, 26 Nov 2024 14:56:54 -0600 Subject: [PATCH] Add logs for video tracking --- src/hooks/tracking/useTrackVideoLesson.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hooks/tracking/useTrackVideoLesson.js b/src/hooks/tracking/useTrackVideoLesson.js index d634ffd..9a77669 100644 --- a/src/hooks/tracking/useTrackVideoLesson.js +++ b/src/hooks/tracking/useTrackVideoLesson.js @@ -81,8 +81,13 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa const alreadyCompleted = await checkOrCreateUserLesson(); if (!alreadyCompleted && videoDuration && !completedRef.current && videoPlayed && (paidCourse === false || (paidCourse && decryptionPerformed))) { setIsTracking(true); + console.log('🎥 Starting video tracking - Duration:', videoDuration); timerRef.current = setInterval(() => { - setTimeSpent(prevTime => prevTime + 1); + setTimeSpent(prevTime => { + const newTime = prevTime + 1; + console.log(`⏱️ Time spent: ${newTime}s / ${videoDuration}s (${((newTime/videoDuration)*100).toFixed(1)}%)`); + return newTime; + }); }, 1000); } }; @@ -100,6 +105,7 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa if (isAdmin) return; if (videoDuration && timeSpent >= Math.round(videoDuration * 0.9) && !completedRef.current) { + console.log('🎯 Video reached 90% threshold - Marking as completed'); markLessonAsCompleted(); } }, [timeSpent, videoDuration, markLessonAsCompleted, isAdmin]); @@ -107,4 +113,4 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa return { isCompleted, isTracking }; }; -export default useTrackVideoLesson; +export default useTrackVideoLesson; \ No newline at end of file