# 接口文档
# _init(opts)
参数
- {Object} opts
- {Boolean} debug(废弃,但是仍然支持,推荐使用 env): 上报埋点是否为测试数据。true:是,false:否,默认:false。登录AECORE (opens new window),创建应用,开通采集服务即可查看埋点数据。
- {String} env(推荐): 配置上报埋点数据是测试还是正式。prod:正式,test:测试,默认:prod。登录AECORE (opens new window),创建应用,开通采集服务即可查看埋点数据。
- {Boolean} customUrl: 自定义上报埋点接口地址。java 后端埋点上报 SDK 说明文档 (opens new window),这个设置是为了定位埋点丢失情况,如果接入该采集服务 sdk,但是埋点数据总是后台缺失,可以通过此方式定位哪个环节有问题,但是默认不使用。
- {Object} opts
用法
初始化 jssdk
Report._init({ env: "prod" });1
# listen(opts)
参数
- {Object} opts
- {Function} onError: 错误日志
- {Object} opts
用法
注册错误日志,在使用 jssdk 接口的过程中出现的错误会被输出,包括接口请求参数错误,接口请求响应错误等等。
Report.listen({ onError: function(res) { console.log(res.msg); } });1
2
3
4
5
# changeApi(type)
参数
- {String} type:埋点上报环境,prod:正式环境,test:测试环境。
用法
token 登录
Report.changeApi("prod");1
# defineCom(opts)
参数
- {Object} opts
用法
全局定义埋点上报的公共数据,这样在进行埋点上报接口调用的时候,会自动带上这些被全局定义的公共数据。但它的优先级低于埋点上报接口中上传的 report 对象。
Report.defineCom({ pcode: "xxxxxx", gid: "xxxxxxxxxx" });1
2
3
4
# getCom
用法
获取当前全局定义的埋点上报的公共数据,注意:只是查看,修正需要调用 defineCom 接口
Report.login_session() .then(function(data) { console.log(data); }) .catch(function(e) { console.log(e); });1
2
3
4
5
6
7
# delCom(arr)
参数
- {Array} arr
- report 对象上的键值组成的数组
- {Array} arr
用法
删除全局定义埋点上报的公共数据
Report.delCom(["spid", "pcode"]);1