iOS SDK - 初始化 SDK

iOS 跟踪器构造方法的配置选项

iOS SDK ⁠-⁠ 初始化 SDK

以下这行命令将为您安装跟踪器及随附的 SDK,让您能够使用跟踪器的所有功能。

  pod 'OpenReplay', '~> 1.0.17'
dependencies: [
    .package(url: "https://github.com/openreplay/ios-tracker.git", from: "1.0.17"),
]

在实例化 OpenReplay 跟踪器时,您可以提供多个配置选项,以自定义录制及录制体验的诸多方面。您必须在构造方法中设置 projectKey 选项。您可以在 OpenReplay 控制面板的 ‘Preferences > Projects’ 下获取该值。

将以下代码添加到您的 AppDelegate.swift 文件中:

// AppDelegate.swift
import OpenReplay

//...

class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

			  // not required if you're using our SaaS version
        OpenReplay.shared.serverURL = "https://your.instance.com/ingest"
				// check out our SDK docs to see available options
        OpenReplay.shared.start(projectKey: "projectkey", options: .defaults)

        // ...
        return true
			}
// SceneDelegate.Swift
import OpenReplay

// ...
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
	let contentView = ContentView()
	.environmentObject(TodoStore())

	if let windowScene = scene as? UIWindowScene {
		let window = TouchTrackingWindow(windowScene: windowScene) // <<<< here
		window.rootViewController = UIHostingController(rootView: contentView)
		self.window = window
		window.makeKeyAndVisible()
	}
}

有关更多详情,请参阅如何在 iOS 回放中对数据进行脱敏

  • crashes: Bool 启用 crashlytics。
  • analytics: Bool 启用对已标记视图的分析跟踪。
  • performances: Bool 启用性能监听器。
  • logs: Bool 启用日志监听器。
  • screen: Bool 启用屏幕录制器。
  • wifiOnly: Bool 强制跟踪器仅在用户具有 wifi 连接时启动。