mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +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();
|
const alreadyCompleted = await checkOrCreateUserLesson();
|
||||||
if (!alreadyCompleted && videoDuration && !completedRef.current && videoPlayed && (paidCourse === false || (paidCourse && decryptionPerformed))) {
|
if (!alreadyCompleted && videoDuration && !completedRef.current && videoPlayed && (paidCourse === false || (paidCourse && decryptionPerformed))) {
|
||||||
setIsTracking(true);
|
setIsTracking(true);
|
||||||
|
console.log('🎥 Starting video tracking - Duration:', videoDuration);
|
||||||
timerRef.current = setInterval(() => {
|
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);
|
}, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -100,6 +105,7 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa
|
|||||||
if (isAdmin) return;
|
if (isAdmin) return;
|
||||||
|
|
||||||
if (videoDuration && timeSpent >= Math.round(videoDuration * 0.9) && !completedRef.current) {
|
if (videoDuration && timeSpent >= Math.round(videoDuration * 0.9) && !completedRef.current) {
|
||||||
|
console.log('🎯 Video reached 90% threshold - Marking as completed');
|
||||||
markLessonAsCompleted();
|
markLessonAsCompleted();
|
||||||
}
|
}
|
||||||
}, [timeSpent, videoDuration, markLessonAsCompleted, isAdmin]);
|
}, [timeSpent, videoDuration, markLessonAsCompleted, isAdmin]);
|
||||||
@ -107,4 +113,4 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa
|
|||||||
return { isCompleted, isTracking };
|
return { isCompleted, isTracking };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useTrackVideoLesson;
|
export default useTrackVideoLesson;
|
Loading…
x
Reference in New Issue
Block a user