Skip to content

Commit

Permalink
更新文档,便于客户理解
Browse files Browse the repository at this point in the history
  • Loading branch information
liangpengfei committed Oct 22, 2022
1 parent 47550b2 commit dce0f0f
Showing 1 changed file with 83 additions and 80 deletions.
163 changes: 83 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var turbo = require("./utils/turbo.min.js");

```javascript
/**
* 此方法会初始化Turbo需要的基础参数
* @param {string} accessToken 项目通行证,在:网站后台-->管理中心-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
* @param {string} client_id 用户唯一标识,如微信小程序/小游戏的openid
* 此方法会初始化Turbo需要的基础参数(需要确保每次启动都必须要调用)
* @param {string} accessToken 项目通行证,在:网站后台-->管理中心-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
* @param {string} client_id 用户唯一标识,如微信小程序/小游戏的openid
*/
turbo.init("your_access_token", "your_client_id");
```
Expand All @@ -33,22 +33,22 @@ turbo.init("your_access_token", "your_client_id");
/**
* 在用户注册或者可以获取到用户唯一性信息时调用,推荐首次安装启动时调用
* 后续其他接口,均需要等register接口完成之后才能继续调用
* @param {string} name 用户名
* @param {string} channel 用户注册渠道
* @param {number} version 用户注册的程序版本
* @param {string} click_id 用户点击广告id 微信小程序/小游戏选填
* @param {string} wx_openid 用户wxopenid 微信小程序/小游戏必填
* @param {string} wx_unionid 微信union_id 微信小程序/小游戏选填
* @param {string} name 用户名(必填)
* @param {string} channel 用户注册渠道(必填)
* @param {number} version 用户注册的程序版本(必填)
* @param {string} click_id 用户点击广告id 微信小程序/小游戏选填
* @param {string} wx_openid 微信open id (微信小程序和小游戏必填)
* @param {string} wx_unionid 微信union id(微信小程序和小游戏选填)
*/

turbo
.register({
name: "your_name",
channel: "your_channel",
name: "user_name",
channel: "user_channel",
version: 123,
click_id: "your_click_id",
wx_openid: "your_wx_openid",
wx_unionid: "your_wx_unionid",
click_id: "user_click_id",
wx_openid: "user_wx_openid",
wx_unionid: "user_wx_unionid",
})
.then(() => {
// 在这之后继续做其他的方法调用
Expand All @@ -58,45 +58,23 @@ turbo
});
```

#### updateData 用户数据更新

```javascript
/**
* 用户数据更新
* @param {string} click_id 用户点击广告id 微信小程序/小游戏传入选填
* @param {string} wx_openid 用户wxopenid 微信小程序/小游戏传入
* @param {string} wx_unionid 微信union_id 微信小程序/小游戏选填
*/

turbo
.updateData({
click_id: "your_click_id",
wx_openid: "your_wx_openid",
wx_unionid: "your_wx_unionid",
})
.then(() => {
wx.showToast({
title: "updateData successfully",
});
});
```

#### handleEvent 埋点事件报
#### handleEvent 埋点事件上报

```javascript
/**
* 埋点事件上报
* @param {string} event_type 埋点事件类型 分为
activate 激活
register 注册
pay 付费
twice 次留
key_active 关键行为
start 程序启动 每次启动结束之后都调用一次
* @param properties event_type=pay时必填,结构体,包含以下字段
amount: 原价金额,单位为分
real_amount: 实际付款金额,单位为分
* @param {number} timestamp 事件发生时间 毫秒时间戳
activate 激活
register 注册
pay 付费
twice 次留
key_active 关键行为
start 程序启动 每次启动结束之后都调用一次
* @param properties event_type=pay时必填,结构体,包含以下字段
amount: 原价金额,单位为分
real_amount: 实际付款金额,单位为分
* @param {number} timestamp 事件发生时间 毫秒时间戳
*/

turbo
Expand All @@ -115,38 +93,6 @@ turbo
});
```

#### consumerEvent 消费事件

```javascript
/**
* 消费事件
* @param {string} event_type 消费事件类型 分为
START 小程序启动
CLICK_SURVEY 点击开始填写问卷
SUBMIT_SURVEY 提交问卷
CLICK_RECOMMEND_COMMODITY 点击查看推荐商品
ADD_TO_CART 加入购物车
PRIVILEGE 礼遇
SETTLEMENT 结算
PAY 支付
* @param {number} ts 事件发生时间 毫秒时间戳
* @param {number} amount 原价金额 单位为分 event_type=PAY时需要
* @param {number} real_amount 实际付款金额 单位为分 event_type=PAY时需要
*/

turbo
.consumerEvent({
event_type: "PAY",
ts: 1000,
amount: 1000,
real_amount: 2000,
})
.then(() => {
wx.showToast({
title: "handleConsumerEvent successfully",
});
});
```

#### queryUser 查询用户信息

Expand All @@ -159,7 +105,7 @@ turbo
* 4. aid 广告计划ID
* 5. cid 广告创意ID
* 6. advertiser_id 广告账户ID
*
*
* 返回示例如下,具体可以打印返回的data查看
* "user_list": [
{
Expand All @@ -180,6 +126,63 @@ turbo.queryUser().then((data) => {
});
```


#### updateData 用户数据更新

```javascript
/**
* 用户数据更新
* @param {string} click_id 用户点击广告id 微信小程序/小游戏传入选填
* @param {string} wx_openid 用户wxopenid 微信小程序/小游戏传入
* @param {string} wx_unionid 微信union_id 微信小程序/小游戏选填
*/

turbo
.updateData({
click_id: "user_click_id",
wx_openid: "user_wx_openid",
wx_unionid: "user_wx_unionid",
})
.then(() => {
wx.showToast({
title: "updateData successfully",
});
});
```

#### consumerEvent 消费事件

```javascript
/**
* 消费事件
* @param {string} event_type 消费事件类型 分为
START 小程序启动
CLICK_SURVEY 点击开始填写问卷
SUBMIT_SURVEY 提交问卷
CLICK_RECOMMEND_COMMODITY 点击查看推荐商品
ADD_TO_CART 加入购物车
PRIVILEGE 礼遇
SETTLEMENT 结算
PAY 支付
* @param {number} ts 事件发生时间 毫秒时间戳
* @param {number} amount 原价金额 单位为分 event_type=PAY时需要
* @param {number} real_amount 实际付款金额 单位为分 event_type=PAY时需要
*/

turbo
.consumerEvent({
event_type: "PAY",
ts: 1000,
amount: 1000,
real_amount: 2000,
})
.then(() => {
wx.showToast({
title: "handleConsumerEvent successfully",
});
});
```

#### License

Under BSD license,you can check out the license file

0 comments on commit dce0f0f

Please sign in to comment.