Skip to content

Commit

Permalink
Merge pull request #11 from l-hammer/uvpv_zap
Browse files Browse the repository at this point in the history
✨uvpv support routeUpdate mode
  • Loading branch information
LHammer authored Jul 30, 2019
2 parents 86b1efe + 48c48e9 commit a23a112
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import trackEvents from "./track-events"
Vue.use(VTrack, {
trackEvents, // 埋点事件对象
trackEnable: {
UVPV: true, // 是否开启UVPV统计,默认为false
UVPV: true, // 是否开启UVPV统计,v0.8.3新增routeUpdate,即在当前路由参数发生改变时埋点,默认为false
TONP: true // 是否开启页面停留时长统计,默认为false
}
})
Expand Down
2 changes: 2 additions & 0 deletions docs/dist/js/app.1f68f820.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dist/js/app.1f68f820.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/dist/js/app.96608e54.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/dist/js/app.96608e54.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=dist/favicon.ico><link href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/nord.min.css rel=stylesheet><title>v-track</title><link href=dist/css/app.1efa72a7.css rel=preload as=style><link href=dist/css/chunk-vendors.bf068a49.css rel=preload as=style><link href=dist/js/app.96608e54.js rel=preload as=script><link href=dist/js/chunk-vendors.c94e27ba.js rel=preload as=script><link href=dist/css/chunk-vendors.bf068a49.css rel=stylesheet><link href=dist/css/app.1efa72a7.css rel=stylesheet></head><body><noscript><strong>We're sorry but v-track doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=dist/js/chunk-vendors.c94e27ba.js></script><script src=dist/js/app.96608e54.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=dist/favicon.ico><link href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/nord.min.css rel=stylesheet><title>v-track</title><link href=dist/css/app.1efa72a7.css rel=preload as=style><link href=dist/css/chunk-vendors.bf068a49.css rel=preload as=style><link href=dist/js/app.1f68f820.js rel=preload as=script><link href=dist/js/chunk-vendors.c94e27ba.js rel=preload as=script><link href=dist/css/chunk-vendors.bf068a49.css rel=stylesheet><link href=dist/css/app.1efa72a7.css rel=stylesheet></head><body><noscript><strong>We're sorry but v-track doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=dist/js/chunk-vendors.c94e27ba.js></script><script src=dist/js/app.1f68f820.js></script></body></html>
2 changes: 1 addition & 1 deletion docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Vue.use(CollapseItem);
Vue.use(VueTrack, {
trackEvents,
trackEnable: {
UVPV: true,
UVPV: "routeUpdate",
TONP: true
}
});
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/started.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import trackEvents from "./track-events";
Vue.use(VTrack, {
trackEvents, // 埋点事件对象
trackEnable: {
UVPV: true, // 是否开启UVPV统计,默认为false
UVPV: true, // 是否开启UVPV统计,v0.8.3新增routeUpdate,即在当前路由参数发生改变时埋点,默认为false
TONP: true // 是否开启页面停留时长统计,默认为false
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v-track",
"version": "0.8.2",
"version": "0.8.3",
"description": "一个基于Vue指令的埋点插件",
"author": "LHammer <[email protected]>",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 宋慧武
* @Date: 2019-03-06 17:49:29
* @Last Modified by: 宋慧武
* @Last Modified time: 2019-07-30 20:15:53
* @Last Modified time: 2019-07-30 21:46:22
*/
import * as hooks from "./hooks";

Expand Down Expand Up @@ -68,6 +68,12 @@ export default class VTrack {
});
}
},
beforeRouteUpdate(_, __, next) {
if (trackEnable.UVPV && trackEnable.UVPV === "routeUpdate") {
trackEvents.UVPV(this);
}
next();
},
// 页面停留时间
beforeRouteLeave(_, __, next) {
TRACK_TONP(this, this.PAGE_ENTER_TIME);
Expand Down

0 comments on commit a23a112

Please sign in to comment.