Tianshuo

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

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