千匠星云 统计埋点 -- @nebular.js/bury
安装 - install
yarn add @nebular.js/bury
# or
npm install @nebular.js/bury
导入 - import
import { bury, increase } from "@nebular.js/bury";
使用 - use
bury({
// 环境参数,布尔
agent: {
// 平台
platform: true,
// 网络
net: true,
// 系统 OS
os: true,
// 内核
core: true,
// 浏览器
browser: true,
// 外壳(如:QQ、360等)
shell: true,
// 屏幕尺寸
screen: true,
// 原始 UA 信息
ua: true,
// 拓展参数
extend: {
// 示例
uuid: `uuid`
}
},
process: {
// 心跳时长(毫秒)
heart: 10000,
// 存储命名空间,默认:bury
namespace: `burning`
},
// 事件行为
event: {
// 属性标记名
attr: `action`
},
http: {
// 默认地址,可以不填
uri: `http://commerce.xytest.qjclouds.com/`,
// 参数预设,可用于修改请求对象的初始化行为
preset: {
headers: {
hello: `world`
}
},
// 参数拓展,将合并于每次请求
extend: {
custom: `value`
}
}
});
<!-- 配置 action 信息,用于信息统计 -->
<div action="information">press me to save info into storage</div>
// 项目数据可由 increase 函数提交
increase({ name: `joker` });
// 隐藏用法:increase 能接收一个 function 作为参数,并将其运行结果作为 提交参数
increase(params => {
// params 为环境自带参数
return {
name: `joker`
}
});
在 HTML5 中使用 - use in H5
<!-- 引入依赖包 -->
<script src="https://nebular.oss-cn-shanghai.aliyuncs.com/bury/nebular.bury.js"></script>
<script>
// 初始化
window.bury({
/* 参数配置 */
});
// 项目数据
window.increase({
name: `joker`
});
</script>
数据格式 -- Data Format
{
/* start、heart */
"type": "heart",
/* event for commit */
"event": [
{
/* Timestamp */
"time": "stamp",
/* encode by JSON.stringify */
"info": "information"
}
]
}