hookehuyr

fix(埋点): 修复学习时长埋点逻辑并优化参数

添加schedule_id参数到埋点数据
调整埋点触发间隔为3秒
在组件卸载时添加埋点结束逻辑
在图片附件或附件不存在时自动触发埋点
......@@ -438,8 +438,6 @@ onMounted(async () => {
})
}, 500);
if (courseId.value) {
const { code, data } = await getScheduleCourseAPI({ i: courseId.value });
if (code) {
......@@ -466,10 +464,12 @@ onMounted(async () => {
course_lessons.value = detail.data.schedule || [];
}
}
// 图片附件或者附件不存在
// 进入后直接执行学习时长埋点
if(course.value.course_type === 'image' || !course.course_type) {
startAction();
}
}
})
// 提交评论
......@@ -579,6 +579,7 @@ const onPopupLoad = async () => {
// 在组件卸载时移除滚动监听
onUnmounted(() => {
window.removeEventListener('scroll', handleScroll);
endAction();
});
// 提交弹窗中的评论
......@@ -691,6 +692,9 @@ const downloadFile = ({ title, url }) => {
}).catch((error) => {
console.error('下载文件出错:', error);
});
// 学习时长埋点开始
startAction();
}
/**
......@@ -750,7 +754,9 @@ const startAction = (item) => {
window.actionTimer = setInterval(() => {
console.warn('持续操作中', uuid);
let paramsObj = {}
let paramsObj = {
schedule_id: courseId.value,
}
// 更新当前播放位置(如果是视频播放)
if (videoPlayerRef.value && videoPlayerRef.value.getPlayer()) {
......@@ -782,7 +788,7 @@ const startAction = (item) => {
addRecord(paramsObj);
// 这里可以添加需要持续执行的具体操作
}, 1000); // 每秒执行一次,可以根据需求调整时间间隔
}, 3000); // 3秒执行一次,可以根据需求调整时间间隔
}
/**
......