埋点,im,客服删除

This commit is contained in:
谢宇宁
2026-10-08 21:20:52 +07:00
parent c39daacc6d
commit d25c71dc51
146 changed files with 118 additions and 8495 deletions
@@ -16,7 +16,6 @@ import HlsJSPlayer from 'xgplayer-hls.js';
import UserApi from '@/service/user';
import { addVideoHistory } from '@/utils';
import { HistoryVideoType } from '@/enums/app';
import { analyticsEventVideo } from '@/utils/eventReporter/analytics';
import { judgeTime } from '@/utils/index';
import {
bindXgTrialProgressGuard,
@@ -54,7 +53,6 @@ const emitTrialUnlockPopup = () => {
}, 300);
};
let player: any = null; //播放器实例
let isReport = ref(false); // 视频埋点锁
let isPreview = ref(false); // 是否预览视频
let videoUrl = ref(''); // 播放地址
/** 当前是否使用 H.265 资源 */
@@ -68,36 +66,12 @@ const state = reactive({
playTimer: <any>'', // 统计时使用:时间计时器
playTime: 0, // 统计时使用:播放时间
hideProgress: false,
isCompleteReported: false, // 播放完成事件(>=95%)是否已上报,避免重复
isSecondPlayReported: false, // 播放超过 1 分钟后二次 play 埋点锁
});
// 进度达到 95% 视为播放完成(自然播放或拖动到 95% 都算)
const checkVideoComplete = () => {
if (state.isCompleteReported) return;
const duration = Number(player?.video?.duration) || 0;
const currentTime = Number(player?.video?.currentTime) || 0;
if (duration > 0 && currentTime / duration >= 0.9) {
state.isCompleteReported = true;
analyticsEventVideo(videoInfo.value, 'MOVIE', Math.ceil(currentTime || 1), 'video_complete', '播放完成');
}
};
const checkSecondVideoPlay = () => {
if (state.isSecondPlayReported) return;
const duration = Number(player?.video?.duration) || 0;
const currentTime = Number(player?.video?.currentTime) || 0;
if (currentTime / duration < 0.9) {
state.isSecondPlayReported = true;
analyticsEventVideo(videoInfo.value, 'MOVIE', Math.ceil(currentTime || 1), 'video_play', '播放');
}
};
onMounted(() => {
getInfo();
//获取免费观看次数
getFreeWatchCount();
analyticsEventVideo(videoInfo.value, 'MOVIE', 0, 'video_view', '展示');
});
/**
@@ -105,13 +79,9 @@ onMounted(() => {
*/
const pause = () => {
if (!player) return;
const wasPlaying = !player.paused;
player.pause();
clearInterval(state.playTimer);
state.playTimer = '';
if (wasPlaying) {
analyticsEventVideo(videoInfo.value, 'MOVIE', Math.ceil(player?.video?.currentTime || 1), 'video_pause', '暂停');
}
};
/** 点击画面切换播放/暂停 */
@@ -189,7 +159,6 @@ const getInfo = async () => {
* @description 初始化播放器
*/
const previewStartFlag = ref(false); // 是否进行预览时间设置
let suppressPlayAnalytics = false;
let trialLimitHandled = false;
let unbindTrialProgressGuard: (() => void) | null = null;
const pageActive = ref(true);
@@ -208,7 +177,6 @@ const destroyPlayer = (silent = false) => {
unbindH265Fallback?.();
unbindH265Fallback = null;
if (!player) return;
if (!silent) checkSecondVideoPlay();
destroySilently = silent;
try {
player.src = '';
@@ -279,9 +247,6 @@ const initVideo = () => {
req.searchAccessTicket = props.searchAccessTicket;
}
VideoApi.getPlayVideo(req);
if (state.playTime > 1) {
// analyticsEventVideo(videoInfo.value, 'MOVIE', state.playTime, 'video_exit', '播放退出');
}
clearInterval(state.playTimer);
state.playTimer = '';
state.playTime = 1;
@@ -331,9 +296,6 @@ const initVideo = () => {
// 播放
player.on('play', () => {
emit('play');
if (!suppressPlayAnalytics) {
analyticsEventVideo(videoInfo.value, 'MOVIE', Math.ceil(player?.video?.currentTime || 1), 'video_play', '播放');
}
});
/** 仅当明确回到试看区内才清标记;回弹到 limit-ε 时 playCheck 为 true,不能清,否则半屏关了又弹 */
@@ -359,7 +321,6 @@ const initVideo = () => {
player.on('timeupdate', () => {
if (!pageActive.value || !player.hasStart) return;
emit('timeupdate', Number(player?.video?.currentTime) || 0);
checkVideoComplete();
if (playCheck()) {
if (canResetTrialLimitHandled()) {
trialLimitHandled = false;
@@ -369,7 +330,6 @@ const initVideo = () => {
handleTrialLimitReached();
});
player.on('seeked', () => {
checkVideoComplete();
if (!player.hasStart) return;
const clamped = clampTrialSeek();
clearTrialSeekBlock();
@@ -377,9 +337,6 @@ const initVideo = () => {
if (pageActive.value) {
emit('timeupdate', Number(player?.video?.currentTime) || 0);
}
window.setTimeout(() => {
suppressPlayAnalytics = false;
}, 300);
if (clamped) return;
if (!playCheck()) {
handleTrialLimitReached();
@@ -387,7 +344,6 @@ const initVideo = () => {
});
player.on('seeking', () => {
if (!player?.hasStart) return;
suppressPlayAnalytics = true;
if (needsTrialSeekLimit()) {
setTrialFrameBlocked(true);
}