mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-05 00:32:03 +00:00
Add logs for video tracking
This commit is contained in:
parent
89dd52ed8b
commit
d36e61c4f7
@ -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;
|
Loading…
x
Reference in New Issue
Block a user