fix(埋点): 修复学习时长埋点逻辑并优化参数
添加schedule_id参数到埋点数据 调整埋点触发间隔为3秒 在组件卸载时添加埋点结束逻辑 在图片附件或附件不存在时自动触发埋点
Showing
1 changed file
with
13 additions
and
7 deletions
| ... | @@ -438,8 +438,6 @@ onMounted(async () => { | ... | @@ -438,8 +438,6 @@ onMounted(async () => { |
| 438 | }) | 438 | }) |
| 439 | }, 500); | 439 | }, 500); |
| 440 | 440 | ||
| 441 | - | ||
| 442 | - | ||
| 443 | if (courseId.value) { | 441 | if (courseId.value) { |
| 444 | const { code, data } = await getScheduleCourseAPI({ i: courseId.value }); | 442 | const { code, data } = await getScheduleCourseAPI({ i: courseId.value }); |
| 445 | if (code) { | 443 | if (code) { |
| ... | @@ -466,10 +464,12 @@ onMounted(async () => { | ... | @@ -466,10 +464,12 @@ onMounted(async () => { |
| 466 | course_lessons.value = detail.data.schedule || []; | 464 | course_lessons.value = detail.data.schedule || []; |
| 467 | } | 465 | } |
| 468 | } | 466 | } |
| 469 | - | 467 | + // 图片附件或者附件不存在 |
| 468 | + // 进入后直接执行学习时长埋点 | ||
| 469 | + if(course.value.course_type === 'image' || !course.course_type) { | ||
| 470 | + startAction(); | ||
| 471 | + } | ||
| 470 | } | 472 | } |
| 471 | - | ||
| 472 | - | ||
| 473 | }) | 473 | }) |
| 474 | 474 | ||
| 475 | // 提交评论 | 475 | // 提交评论 |
| ... | @@ -579,6 +579,7 @@ const onPopupLoad = async () => { | ... | @@ -579,6 +579,7 @@ const onPopupLoad = async () => { |
| 579 | // 在组件卸载时移除滚动监听 | 579 | // 在组件卸载时移除滚动监听 |
| 580 | onUnmounted(() => { | 580 | onUnmounted(() => { |
| 581 | window.removeEventListener('scroll', handleScroll); | 581 | window.removeEventListener('scroll', handleScroll); |
| 582 | + endAction(); | ||
| 582 | }); | 583 | }); |
| 583 | 584 | ||
| 584 | // 提交弹窗中的评论 | 585 | // 提交弹窗中的评论 |
| ... | @@ -691,6 +692,9 @@ const downloadFile = ({ title, url }) => { | ... | @@ -691,6 +692,9 @@ const downloadFile = ({ title, url }) => { |
| 691 | }).catch((error) => { | 692 | }).catch((error) => { |
| 692 | console.error('下载文件出错:', error); | 693 | console.error('下载文件出错:', error); |
| 693 | }); | 694 | }); |
| 695 | + | ||
| 696 | + // 学习时长埋点开始 | ||
| 697 | + startAction(); | ||
| 694 | } | 698 | } |
| 695 | 699 | ||
| 696 | /** | 700 | /** |
| ... | @@ -750,7 +754,9 @@ const startAction = (item) => { | ... | @@ -750,7 +754,9 @@ const startAction = (item) => { |
| 750 | window.actionTimer = setInterval(() => { | 754 | window.actionTimer = setInterval(() => { |
| 751 | console.warn('持续操作中', uuid); | 755 | console.warn('持续操作中', uuid); |
| 752 | 756 | ||
| 753 | - let paramsObj = {} | 757 | + let paramsObj = { |
| 758 | + schedule_id: courseId.value, | ||
| 759 | + } | ||
| 754 | 760 | ||
| 755 | // 更新当前播放位置(如果是视频播放) | 761 | // 更新当前播放位置(如果是视频播放) |
| 756 | if (videoPlayerRef.value && videoPlayerRef.value.getPlayer()) { | 762 | if (videoPlayerRef.value && videoPlayerRef.value.getPlayer()) { |
| ... | @@ -782,7 +788,7 @@ const startAction = (item) => { | ... | @@ -782,7 +788,7 @@ const startAction = (item) => { |
| 782 | addRecord(paramsObj); | 788 | addRecord(paramsObj); |
| 783 | 789 | ||
| 784 | // 这里可以添加需要持续执行的具体操作 | 790 | // 这里可以添加需要持续执行的具体操作 |
| 785 | - }, 1000); // 每秒执行一次,可以根据需求调整时间间隔 | 791 | + }, 3000); // 3秒执行一次,可以根据需求调整时间间隔 |
| 786 | } | 792 | } |
| 787 | 793 | ||
| 788 | /** | 794 | /** | ... | ... |
-
Please register or login to post a comment