首次事件是指针对某些维度(设备 ID或其他维度的 ID)只记录一次的事件,例如记录某个账号的注册事件,可以使用首次事件来记录,服务端会按照 setCheckId() 设置的 ID 去重,同一 ID 只会记录第一次上报的事件。
注:
预置事件(_appInstall、_appStart、_appEnd)不支持设置为首次事件。
只支持注册和自定义事件设置为首次事件。
方法示例
static void trackFirstEvent(const FSEBaseAttributes& att);
参数说明
| 参数名称 | 参数含义 | 参数类型 | 是否必传 |
| attributes | 首次事件类 | FSEBaseAttributes | 是 |
attributes 参数使用时需要传 SEBaseAttributes 的子类实例,具体说明如下:
| 首次事件 | 参数类型 | 说明 |
|---|---|---|
| 自定义首次事件 | FCustomAttributes | 自定义事件首次事件model类,具体使用方式参考下方示例 |
| 注册事件首次事件 | FRegisterEventAttributes | 注册事件首次事件model类,具体使用方式参考下方示例 |
调用示例
1.注册事件首次事件
FRegisterEventAttributes 类参数介绍:
| 参数名称 | 参数含义 | 参数类型 | 是否必传 |
| checkId | 首次事件校验id | FString | 是(如果未传checkId,则为普通事件) |
| registerType | 注册类型如 "WeChat"、"QQ" 等自定义值 | FString | 是,不超过 32 字符 |
| registerStatus | 注册状态 如 "success" | FString | 否 |
| customProperties | 自定义属性 |
TSharedPtr<FJsonObject> |
否 |
调用示例
FRegisterEventAttributes attribute;
attribute.checkId = "first_check_id";
attribute.registerType = "phone";
attribute.registerStatus = "success";
attribute.customProperties = MakeShareable(new FJsonObject);
attribute.customProperties->SetStringField(TEXT("FirstKey1"), TEXT("FirstValue1"));
USEAnalytics::trackFirstEvent(attribute);
2.自定义事件首次事件
CustomAttributes 类参数说明:
| 参数名称 | 参数含义 | 参数类型 | 是否必传 |
| checkId | 首次事件校验id | string | 是(如果未传checkId,则为普通事件) |
|
customEventName |
自定义事件名称 | string | 是 |
| customProperties | 自定义事件属性 |
TSharedPtr<FJsonObject> |
否 |
调用示例
FCustomAttributes attributeC;
attributeC.checkId = "first_check_id";
attributeC.customEventName = "first_event";
USEAnalytics::trackFirstEvent(attributeC);
注:如果要上报自定义事件首次事件,那么eventName字段为必传字段,否则无法上报。