Tianshuo

Updated 新的事件发送定义(讨论中) (markdown)

1、格式的定义
提交地址:URL,参考:MNS
提交地址:URL?TOKEN=XXXX,参考:MNS
`method:POST`
事件格式(事件之间有序)
... ... @@ -10,20 +10,22 @@ event定义(事件内部无序)
```json
{
"app_key":"应用标示",
"user_id":"用户标示",
"device_id":"设备标示",
"key":"事件名",
"user_id":"用户唯一标示,可以为空",
"device_id":"设备唯一标示(IDFA,OPENUDID)",
"event_id":"事件唯一标示GUID",
"last_event_id":"上一个事件的唯一标示GUID",
"key":"自定义事件名称",
"time":"时间戳",
"type":"事件方法",
"type":"调取的方法",
"properties":{"自定义参数":"键值对的形式"}
}
```
参数级别按先后顺序分为:系统级,全局级,用户
参数级别按先后顺序分为:系统级,会话级,事件
* 系统级:系统启动时由SDK获取到的系统信息,固定以$开头
* 全局级:在整个APP的生命周期里的全局参数
* 用户级:在当前事件里的参数
* 会话级:在整个会话的生命周期里的全局参数(可以修改)
* 事件级:在当前事件里的参数
最后上报的事件为这三个级别依次叠加后的结果。
... ... @@ -35,37 +37,54 @@ event定义(事件内部无序)
| $lib_version | 系统 | `1.2.0` | SDK库版本 |
| $os | 系统 | `iPhone OS` | 操作系统 |
| $os_version | 系统 | `9.1` | 操作系统版本 |
| $model | 系统 | `iPod touch` or `x86_64` | 模具 |
| $watch_model | 系统 | `Apple Watch 38mm` 不重要 | 手表模具 |
| $model | 系统 | `iPod touch` or `x86_64` | 硬件型号 |
| $watch_model | 系统 | `Apple Watch 38mm` 不重要 | 手表型号 |
| $screen_width | 系统 | `1024` | 屏幕宽度 |
| $screen_height | 系统 | `768` | 屏幕高度 |
| $manufacturer | 系统 | `Apple` | 制造商 |
| $app_version | 系统 | `655` | 编译号(Bundle version) |
| $app_release | 系统 | `1.0` | 语义化版本号(Bundle versions string, short) |
| $ios_ifa | 系统 | `xxxxxxxx` | 苹果广告唯一标示 |
| $province | 系统 | `北京` | 省份 |
| $city | 系统 | `北京` | 城市 |
| $province | 系统 | `北京` | 省份,可以忽略 |
| $city | 系统 | `北京` | 城市,可以忽略 |
| $country | 系统 | `中国` | 国家,可以忽略 |
| $wifi | 全局 | `1` or `0` | 是否启用wifi |
| $carrier | 全局 | `中国联通` | 运营商 |
type的取值
| 类型 | 说明 |
|------|------|
| begin_session | 应用启动 |
| end_session | 应用关闭 |
| session_duration | 心跳 |
| track | 普通监测 |
| track_signup | 注册监测(服务器会对用户进行处理) |
| profile_set | 设置profile |
| profile_set_once | 设置一次profile |
| profile_unset | 取消设置profile |
| profile_increment | profile自增长 |
| profile_append | profile追加 |
| profile_delete | profile删除 |
| 类型 | 说明 | 备注 |
|------|------|------|
| begin_session | 应用启动 |应用启动或进入前台时自动触发|
| end_session | 应用关闭 |应用启动退出到后台或者关闭时自动触发|
| session_duration | 心跳 |应用每3分钟发出一次|
| track | 普通监测 |只有这个事件才有key属性|
| track_signup | 注册监测(服务器会对用户进行处理) |用于第一次注册|
| profile_set | 设置profile |批量存放properties为用户属性,覆盖所有已存在的属性|
| profile_set_once | 设置一次profile |批量存放properties为用户属性,只有当属性不存在时才保存|
| profile_unset | 取消设置profile |批量删除已经存在的属性,如果不存在,则不删除|
| profile_increment | profile自增长 |可以对已经存在的属性进行增减,必须已经存在,且为int或者float类型,参数可以为负数|
| profile_append | profile追加 |这个是什么鬼?|
| profile_delete | profile删除 |注销了该用户|
2、缓存机制
A. 离线缓存
所有离线事件均进行缓存,当有网络后,会批量发出这些事件。
B. 服务器确认
如果服务器未能确认成功接收事件,则隔一段事件后,需要重新发出
C. 服务器去重
服务器会记录已经发出事件的GUID,如果某GUID已经接收过,则不会将该事件再次记录,返回客户端消息成功接收(重复信息)。
D. 服务器重排列
服务器会定期梳理事件,尽可能保证last_event_id的事件在event_id的前面。如果出现循环,丢失等情况,则略过。
参考:
https://github.com/sensorsdata
https://github.com/countly
http://help.aliyun.com/product/8315016_mns.html
\ No newline at end of file
* https://github.com/sensorsdata
* https://github.com/countly
* http://help.aliyun.com/product/8315016_mns.html
\ No newline at end of file
... ...