vue-auto-track
v1.4.4
Published
auto tracking for vue
Downloads
33
Readme
环境依赖
uniapp vue2.0
部署步骤
npm install vue-auto-track
import track from 'vue-auto-track'(main.js)
Vue.use(track, { env: 'xx', upload: Promise, size: xxx, constData: Object, pageConfig:Object })
目录结构描述
├├── index.js
└── untils
├── env.js
├── exposure.js //监控组件或者页面元素曝光
├── get-upload.js //收集+上传
├── global.js //全局常量
├── lifecycle.js //小程序生命周期
├── native.js //基础数据采集
├── temp.js
└── tools.js //js方法库
options
| option | type | values | des
| ---------- | ------- | ------- | -----------------------------------------------
| env | String | require | 'wx' 或'h5'
| upload | Promise | require | 返回结果为 Promise 对象的请求方法
| size | Number | require | 触发上传数据大小
| constData | Object | custom | 每个埋点事件触发携带的基础常量如: ip,版本,平台等
| dyData | Object | custom | 每个埋点事件触发携带的动态变量: 各类唯一 id
| pageConfig | Object | custom | 页面配置项如: 曝光的节点元素
Vue.use(track, {
env: "wx",
upload: (data) => request("https://xxxxx.xxxxx.xxxxx/eReport", { data }),
size: 10000,
constData: {
app_cd: "jixuan",
platform: "wx_h5",
client_version: "吉选平台V3.1.0",
},
pageConfig,
dyData() {
return {};
},
plugins: [
(eventId, data) => uma.trackEvent(eventId), //eventId可以通过data加工
],
});
pageConfig
| option | type | values | des | | ----------- | ------ | ------- | -------------- | | selectorsPg | Array | require | 页面级元素曝光 | | selectorsCp | Array | require | 组件级元素曝光 | | name | String | require | 页面级元素曝光 | | route | String | require | 组件级元素曝光 |
export const homePage = {
//监控曝光
selectorsPg: [
{
selector: ".back-top",
multipule: false,
},
],
selectorsCp: [
{
selector: ".goods__wrapper",
multipule: false,
},
],
name: "首页",
route: "pages/tabs/index/index",
};