分析框架
要使用此 Pod,请按照以下步骤在您的 Xcode 项目中操作
pod 'RTAMSDK'
pod install
。要使用此 Swift 包在您的 Xcode 项目中,请按照以下步骤
import RTAMSDK
您需要将以下代码添加到您的 Info.plist 文件中,并将 FILL_YOUR_WRITE_KEY_HERE 替换为您的写入密钥
<key>RTAMSDKConfig</key>
<dict>
<key>writeKey</key>
<string>FILL_YOUR_WRITE_KEY_HERE</string>
</dict>
在您的 UIApplicationDelegate 中导入 RTAMSDK 模块
import RTAMSDK
在您的应用代理的 application(_:didFinishLaunchingWithOptions:) 方法中配置 RTAMSDK 共享实例
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
RTAM.start()
return true
}
分析将自动初始化并为您收集数据。您也可以使用以下方法手动跟踪事件
RTAM.track(name: "Event name", properties: [String : Any]?)
您可以将任何自定义属性跟踪任何事情
struct UserLoggedInEventProperties: Codable {
var username: String
var mail: String
}
let userLoggedInEventProperties = UserLoggedInEventProperties(
username: "tester",
mail: "[email protected]"
)
RTAM.track(name: "User LoggedIn", properties: userLoggedInEventProperties)
RTAM.identify(userId: "UserID")
如果您需要添加更多信息的情况
struct UserTraits: Codable {
var name: String
var birthday: String
var phoneNumber: String
}
let traits = UserTraits(
name: "Tester",
birthday: "20/12/2022",
phoneNumber: "+84909090909"
)
RTAM.identify(userId: "UserID", traits: traits)
RTAM.screen(title: "LoginScreen")
属性是描述屏幕的额外信息。它们可以是您想要的任何内容。
struct ScreenProperties: Codable {
var name: String
var loginMethod: String
}
let properties = ScreenProperties(
name: "Login",
loginMethod: "Apple ID"
)
RTAM.screen(title: "LoginScreen", properties: properties)
RTAMSDK 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。