问题描述
目前正在通过 AWS Amplify 和 Pinpoint 实施网络和移动分析。
我注意到 Amplify JS 文档的分析部分与 iOS 和 Android 的相关部分不同,特别是在事件对象可以包含的额外参数/键/值方面。
JS 文档指定了 attributes
属性,而 iOS 和 Android 版本都指定了称为 properties
的内容。请参阅以下片段:
JavaScript
Analytics.record({
name: 'albumVisit',// Attribute values must be strings
attributes: { genre: '',artist: '' }
});
iOS
func recordEvents() {
let properties: AnalyticsProperties = [
"eventPropertyStringKey": "eventPropertyStringValue","eventPropertyIntKey": 123,"eventPropertyDoubleKey": 12.34,"eventPropertyBoolKey": true
]
let event = BasicAnalyticsEvent(name: "eventName",properties: properties)
Amplify.Analytics.record(event: event)
}
安卓
val event = AnalyticsEvent.builder()
.name("PasswordReset")
.addProperty("Channel","SMS")
.addProperty("Successful",true)
.addProperty("ProcessDuration",792)
.addProperty("UserAge",120.3)
.build()
Amplify.Analytics.recordEvent(event)
attributes
和 properties
可以互换吗?我将使用 Amazon QuickSight 构建分析仪表板,最终收集的事件数据将在 S3 上结束,并使用 Athena 进行查询。我需要为 Athena 中的表定义一个架构,根据上述情况,我不确定我可以期望数据 attributes
/properties
采用什么格式。这似乎是亚马逊用于 attributes
和 properties
包含相同类型的事件相关信息。但我很困惑为什么平台之间的命名约定不同。
解决方法
在 iOS 和 Android 上,Amplify Analytics 的字符串和布尔属性被映射到 Pinpoint attributes。双精度和整数属性映射到 Pinpoint metrics。
或者,用表格表示:
放大属性类型(in) | 精确定位(输出) |
---|---|
字符串 | 属性 |
布尔值 | 属性 |
整数 | 公制 |
双人 | 公制 |
(参考 Amplify 的 Android code,iOS code。)
,万一其他人注意到他们的文档中对此缺乏解释...通过移动 SDK 添加的任何 property
都将出现在记录事件负载的 attributes
对象中。