当您的应用服务器自行收集了一些用户行为,而不是在App端侧直接上报的用户行为,同时您又希望将这些用户行为应用到高级分析提供的各种分析报告中,您可以在其应用服务器调用此接口,通过服务端上报其自行收集的用户行为。通过此接口上报的用户行为不能脱离分析服务SDK上报而独立存在,只是分析服务SDK上报的补充。
承载协议 | HTTPS POST |
|---|---|
接口方向 | 开发者回调接口服务器->分析服务服务器 |
接口URL | {rootUrl}/analytics/datacollection/import/event 说明: {rootUrl}:请参见接口访问路径获取。 |
数据格式 | 请求消息:Content-Type: application/json 响应消息:Content-Type: application/json |
Request Header
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
x-product-id | 是 | String | 用户在AppGallery Connect上的Product ID。 |
x-app-id | 是 | String | 用户在AppGallery Connect上的App ID。 |
Authorization | 是 | String | 鉴权信息。请参见基于OAuth 2.0开放鉴权。 说明: Bearer后面拼接空格,再拼接获取的access_token。 |
Request Body
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
data_type | 是 | Integer | 数据类型,标记是否为用户行为。 固定填写为3。 |
protocol_version | 是 | String | 协议版本号。 固定填写为1。 |
productid | 是 | String | 用户在AppGallery Connect上的Product ID。 |
appid | 是 | String | 用户在AppGallery Connect上的App ID。 |
package_name | 是 | String | 开发者的应用包名。 如果为Web应用则填写为appid。 |
requestid | 是 | String | 上报数据时随机生成的一段32个字符的16进制随机码,每次请求生成。 |
timestamp | 是 | Long | 事件上报的时间,1970年到现在的毫秒数。 |
event_set | 是 | json | 事件信息。 |
event_set数据结构说明
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
aaid | 是 | String | 匿名用户标识,通过HMS Core端侧getAAID接口获取。 |
userid | 否 | String | 用户ID。 |
oaid | 否 | String | 开放广告标识符(Open Advertising ID),若是iOS终端,则取IDFA的值;若是Android终端,则优先取OAID的值,如果获取不到则取GAID的值。 |
oaid_source | 否 | String | OAID的来源,枚举值:
|
_oaid_tracking_flag | 否 | boolean | 是否允许广告跟踪。如果允许跟踪(即没有打开“限制广告跟踪”开关),则为true;如果不允许跟踪(即打开了“限制广告跟踪”开关),则为false。 |
eventid | 是 | String | 事件ID。 |
eventtime | 是 | Long | 事件发生时间,1970年到现在的毫秒数。 |
event_session_name | 是 | String | 事件session标识。 |
first_session_event | 否 | String | 事件session是否刷新。 |
properties | 否 | Json | 事件参数。 |
POST /analytics/datacollection/import/event HTTP/1.1
Content-Type: application/json; charset=UTF-8
Content-Length: xxxx
Accept: application/json
Authorization: Bearer 78C2395236BBF4262CAE4F1172E327C2929AD63EAA0395961A49DEBC3B6F8339
x-product-id: sample-productid
x-app-id: sample-appid
{
"data_type":3,
"protocol_version":"1",
"requestid":"083e920d3f2b4f6aaa2ffba348e58d75",
"timestamp":1624435942860,
"appid":"101282071",
"productid":"98433080309583386",
"package_name":"com.huawei.test",
"event_set":[
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"eventtime":1587867045291,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781700",
"eventid":"$EnterScreen",
"first_session_event":"true",
"properties":{
"$PrevActivityName":"",
"$PrevActivityId":"",
"$CurActivityName":"https://localhost:30401/",
"$CurActivityId":"https://localhost:30401/"
}
},
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"androidid":"",
"eventtime":1587867045292,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781701",
"eventid":"notification_received",
"first_session_event":"false",
"properties":{
"exam_level":"1-1",
"exam_difficulty":"high",
"exam_price":39
}
},
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"androidid":"",
"eventtime":1587867045291,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781700",
"eventid":"$EnterScreen",
"first_session_event":"true",
"properties":{
"$PrevActivityName":"",
"$PrevActivityId":"",
"$CurActivityName":"https://localhost:30401/",
"$CurActivityId":"https://localhost:30401/"
}
}
]
} 状态码为200时:
Response Header
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
Content-Type | 是 | application/json | 响应消息的数据格式。 |
Response Body
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
result_code | 是 | String | 响应码,请参见错误码。 |
result_msg | 是 | String | 响应描述。 |
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Connection: Close Content-Length: xxxx { "result_code":"0", "result_msg":"success" }