iOS SDK ⁠-⁠ Initializing the SDK

The following line will install the tracker and with it the SDK for you to take advantage of all tracker features.

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

When instantiating OpenReplay’s tracker, there are several configuration options you can provide to customize many aspects of the recording and the recording experience. You must set the projectKey option in the constructor. You can get this value from your OpenReplay dashboard under ‘Preferences > Projects’.

Add the following code to your AppDelegate.swift file:

// 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()
  }
}

See how to sanitize data in iOS replays for more details.

  • crashes: Bool Enables crashlytics.
  • analytics: Bool Enables analytics tracking of marked views.
  • performances: Bool Enables performance listener.
  • logs: Bool Enables logs listener.
  • screen: Bool Enables screen recorder.
  • wifiOnly: Bool Forces tracker to start only if user has a wifi connection.