Screen Views
Record native iOS screen-view events from UIKit, SwiftUI hosting controllers, or app-owned route names.
Screen-view events give Ansight explicit navigation breadcrumbs for timelines, replay, and AI summaries.
Manual Screen Views
try AnsightRuntime.shared.screenViewed(
"Checkout",
details: ["route": "/checkout"]
)
Use stable names and compact details:
route=/checkouttab=profilepresentation=modalentry=push-notification
Automatic UIKit Capture
The aggregate developer defaults enable UIKit lifecycle capture. The SDK observes foreground view-controller appearance and records screen-view events using the view-controller class name by default.
Disable automatic screen-view capture when you want fully manual routing:
let options = try AnsightOptions.createBuilder()
.withLifecycleCapture(
AnsightLifecycleCaptureOptions(
enabled: true,
captureAppLifecycle: true,
captureScreenViews: false
)
)
.build()
SwiftUI Route Names
SwiftUI screens hosted through UIHostingController can use the hosting root type as a fallback. Apps with custom routing can provide a resolver:
AnsightRuntime.shared.setScreenRouteResolver(
AnsightScreenRouteResolver { context in
guard context.swiftUIRootTypeName == "RootView" else {
return nil
}
return AnsightScreenRoute(name: "Home", details: ["route": "/"])
}
)
Why Details Matter
Better screen metadata makes replay and downstream analysis more useful. A stable screen name plus lightweight route or presentation details helps explain what the user saw when a log, touch, screenshot, or metric spike occurred.