1.3.7 • Published 5 months ago
dyz_link v1.3.7
目的
智链引擎事件上报工具方法
安装
npm install dyz_link
//或
yarn add dyz_link
参数说明
init方法参数
参数 | 说明 | 类型 | 必需 | 默认值 |
---|---|---|---|---|
assessToken | 安全密钥 | String | 是 | 无 |
assessSecret | assess secret | String | 是 | 无 |
projectId | 项目 id | String | 是 | 无 |
uid | 用户 id | String | Number | 否 | 无 |
jump | 上报成功是否自动跳转 | Boolean | 否 | true |
上报自定义事件参数
参数 | 说明 | 类型 | 必需 | 默认值 |
---|---|---|---|---|
event | 事件名称 | String | 是 | 无 |
customData | 自定义事件参数 | any | 否 | 无 |
方法说明
方法名 | 说明 | 类型 | 参数 | 返回值 |
---|---|---|---|---|
init | SDK 初始化 | Function | (init 方法参数,()=>{}) | Promise |
setIdentity | 设置用户(如有用户体系) | Function | (用户 id,()=>{}) | Promise |
install | 上报安装事件 | Function | ((data)=>{}) | Promise |
open | 上报打开事件 | Function | ((data)=>{}) | Promise |
customEvent | 上报自定义事件 | Function | (自定义事件参数,(data)=>{}) | Promise |
使用
//1.引入
import branch from 'dyz_link';
//2.初始化(必须先初始化后再调用上报方法)
const params = {
"assessToken": "your assess token",
"assessSecret": "your assess secret",
"projectId": "your projectId"
}
branch.init(params).then(() => {
console.log("初始化成功、可调用上报方法")
}).catch(error => {
console.log("初始化失败", error)
})
//或
branch.init(params,(data) => {
if(data.state == "success"){
console.log("初始化成功、可调用上报方法")
}else{
console.log("初始化失败", data.msg)
}
})
//设置用户(如有用户体系)
branch.setIdentity("userId").then(()=>{
console.log("用户成功")
})
//3.调用
//上报安装事件
branch.install().then((data) => {
console.log("上报成功", data)
}).catch(error => {
console.log("上报失败", error)
})
//上报打开事件
branch.open().then((data) => {
console.log("上报成功", data)
}).catch(error => {
console.log("上报失败", error)
})
//上报自定义事件
const params = {
"event": "Event name",
"customData": [{"key": "自定义事件参数键","value": "自定义事件参数值"}]
}
branch.customEvent(params).then((data) => {
console.log("上报成功", data)
}).catch(error => {
console.log("上报失败", error)
})
1.3.7
5 months ago
1.3.6
5 months ago
1.3.5
5 months ago
1.3.3
6 months ago
1.3.2
6 months ago
1.3.1
6 months ago
1.3.0
7 months ago
1.2.9
7 months ago
1.2.8
7 months ago
1.2.7
7 months ago
1.2.6
7 months ago
1.2.5
7 months ago
1.2.4
7 months ago
1.2.3
7 months ago
1.2.2
7 months ago
1.2.1
7 months ago
1.2.0
7 months ago
1.1.9
7 months ago
1.1.8
7 months ago
1.1.7
7 months ago
1.1.6
7 months ago
1.1.5
7 months ago
1.1.4
7 months ago
1.1.3
7 months ago
1.1.2
7 months ago
1.1.1
7 months ago
1.1.0
7 months ago
1.0.9
7 months ago
1.0.8
7 months ago
1.0.7
7 months ago
1.0.6
7 months ago
1.0.5
7 months ago
1.0.4
7 months ago
1.0.3
7 months ago
1.0.2
7 months ago
1.0.1
7 months ago