diff --git a/src/main.ts b/src/main.ts index 39fe288..4afda4e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,30 +32,12 @@ declare global { } } -// 页面停留时间 -let pageStayTime = 0; - // 定义路由是否可以返回的判断 const routerCanGoBack = () => { const position = router.options.history.state?.position; return typeof position === 'number' && position > 0; }; router.beforeEach((to, from, next) => { - // 离开页面的时候结束记录时间 - const duration = Date.now() - pageStayTime; - pageStayTime = 0; - - const collectUrl = ['/ad/', '/share/']; - console.log(`is collect page`, collectUrl.some((url) => from.path.startsWith(url))); - - // 判断是否离开需要采集的页面 - if (collectUrl.some((url) => from.path.startsWith(url))) { - // alert(`duration: ${duration}`); - const sensors = inject('sensors'); - sensors.track('pageStayTime', { - duration - }); - } if (to.meta?.title) document.title = to.meta.title as string; if (to.query.digitalYiliToken) { @@ -73,37 +55,8 @@ router.beforeEach((to, from, next) => { next(); }); -router.afterEach((to, from) => { - // 页面导航结束的时候开始记录时间 - pageStayTime = Date.now(); - -}); app.use(createPinia()); app.use(router); // 神策数据插件 -app.use(sensorsData(), { - // 单页面配置,默认关闭。开启后自动监听 URL 有变化就会触发 $pageview 事件 - is_track_single_page: function () { - return false; - }, - scrollmap: { - // Web 视区停留 - collect_url: function () { - // 需要采集的页面 - const urls = ['/ad/', '/share/']; - console.log(`collect_url`, isCollectUrl(urls)); - - return isCollectUrl(urls); - } - }, - heatmap: { - //是否开启触达图,default 表示开启,自动采集 $WebStay 事件,可以设置 'not_collect' 表示关闭。 - //需要 Web JS SDK 版本号大于 1.9.1 - scroll_notice_map: 'default', - scroll_delay_time: 4000, - //单位秒,预置属性停留时长 event_duration 的最大值。默认5个小时,也就是300分钟,18000秒。 - scroll_event_duration: 18000, - get_vtrack_config: true - } -}); +app.use(sensorsData()); app.mount('#app'); diff --git a/src/views/AD/Index.vue b/src/views/AD/Index.vue index bc36e42..915d23e 100644 --- a/src/views/AD/Index.vue +++ b/src/views/AD/Index.vue @@ -1,26 +1,40 @@