datahunter-sdk
v1.1.1
Published
- 页面PV自动上报 - 页面关闭(unload)时暂存上报数据。下次打开时自动上报页面关闭数据,随后清除。 - 增加`runtime_id`。当用户在某一浏览器中,打开同一地址多个tab页面时,`runtime_id`会不同。此字段可区分用户不同浏览进程的行为的跟踪,防止多浏览进程交叉导致行为数据混淆。
Downloads
26
Readme
前端埋点SDK
版本更新记录
v1.1
- 页面PV自动上报
- 页面关闭(unload)时暂存上报数据。下次打开时自动上报页面关闭数据,随后清除。
- 增加
runtime_id
。当用户在某一浏览器中,打开同一地址多个tab页面时,runtime_id
会不同。此字段可区分用户不同浏览进程的行为的跟踪,防止多浏览进程交叉导致行为数据混淆。
v1.1.1
- 增加
hashchange
事件自动上报
发送文档结构
{
distinct_id: '',
type: '',
event: '',
browser: {
width: 0,
height: 0,
version: '',
},
uri: {
url: '',
path: '',
params: {},
preventPath: '',
},
user: {
user_id: '',
login_time: '',
loginOut_time: ''
},
properties: {
}
}
接口
init
初始化埋点环境。该命令在SDK植入(浏览器端)时自动运行,无需单独执行。
| 条目 | 说明 | | ---- | :----: | | 调用 | pulsars.init() | | 参数 | 无 |
项目src下新建文件夹sdk
<div dh-handle="test">test</div>
import Ds from 'dh-sdk';
// 在实例化之前添加方法 此方法与html关联
// 参数1与html属性dh-handle相对应 被点击时会上报数据
Ds.use('test', (track, obj)=> {
track('$webClick', {
step: 1,
...obj
})
})
export const ds = new Ds();
ds.login('user_id') // 在登录的地方设置
export const dsMethods = {
'/api/test': ({count}) => {
ds.track('事件名称', {count})
},
'/api/test1': ({count}) => {
ds.track('事件名称', {count})
},
}
asyncRequest文件夹下的axios
import {dsMethods} from '@/sdk';
const result = (response, msg, url) => {
return new Promise((resolve, reject) => {
response
.then(res => {
const errMsg = errorCode[res.data.code] || res.data.msg;
switch (Number(res.data.code)) {
case 200:
msg && message.success(msg)
resolve(res.data.msg)
dsMethods[url] && dsMethods[url](res.data.msg)
break;
default:
// message.error(errMsg);
reject({
...res.data,
msg: errMsg
})
break;
}
})
.catch(err => {
console.log('network err')
})
})
}