Configure data capture settings in a native iOS app

You can customize how the Connect library captures data from your app. In native iOS projects, these settings are defined in the AutoLayout configuration object.

Configuration options

The AutoLayout object supports two levels of configuration:

  • To customize settings for all screens of your app, use the GlobalScreenSettings object.
  • To configure rules for a particular screen, add a ScreenName object where ScreenName is the name of the screen.
📘

Note

You can combine global and screen-specific rules in the same configuration.

Configuration properties

PropertyValuesDescription
CaptureLayoutDelayNumber (milliseconds). Default: 1.The time the library waits before capturing the layout of a screen or taking a screenshot. Applies to ScreenChange and ScreenShot events. Consider increasing the default for screens that take longer to render — a blank screen in session replay often indicates the delay is too short.
CaptureLayoutOn0 — disabled. 1 — on user gesture. 2 — on view controller load (default).Controls when the library captures the screen layout.
CaptureScreenshotOn0 — disabled. 1 — on user gesture. 2 — on view controller load (default).Controls when the library takes a screenshot on view controller load events. If set to 0 and ScreenShot is true, screenshots are still captured on other user interaction and gesture events.
CaptureScreenVisitsBoolean. Default: false.Tracks screen load and unload events, showing how users navigate to each screen. Recommended for screens where CaptureUserEvents is disabled — the two settings do not work together. If CaptureUserEvents is true, this value is ignored.
CaptureUserEventsBoolean. Default: true.Captures user interaction and gesture events. Set to false to pause capture on a specific screen.
MaskingObjectContains properties for protecting personally identifiable information. See Enable privacy protection in the Connect iOS SDK.
NumberOfWebViewsNumberThe number of WKWebView objects on the screen. The library waits until all of them have loaded before capturing the screen.
ScreenChangeBoolean. Default: true.Tracks screen changes, showing how users navigate between screens.
ScreenShotBoolean. Default: true.Controls screenshot capture for screen change, user interaction, layout capture, and gesture events.

Setup

The SDK ships with a built-in default configuration. If the defaults work for your app, no setup is needed.

To customize the configuration, pass a layout dictionary to ConnectConfig.Layout(autoLayout:) at initialization. This is the recommended approach — it keeps configuration explicit, version-controlled, and unaffected by SDK updates.

let layoutConfig: [AnyHashable: Any] = [
    "AutoLayout": [
        "GlobalScreenSettings": [
            "ScreenChange": true,
            "CaptureLayoutDelay": 1,
            "ScreenShot": true,
            "CaptureUserEvents": true,
            "CaptureScreenVisits": false,
            "CaptureLayoutOn": 2,
            "CaptureScreenshotOn": 2
        ],
        "StartViewController": [
            "DisplayName": "Start",
            "CaptureLayoutDelay": 0,
            "NumberOfWebViews": 1,
            "ScreenShot": true,
            "CaptureScreenshotOn": 2
        ]
    ]
]

ConnectSDK.shared.enable(
    with: ConnectConfig(
        appKey: "YOUR_APP_KEY",
        postURL: "YOUR_COLLECTOR_URL",
        layout: ConnectConfig.Layout(autoLayout: layoutConfig)
    )
)

Runtime overrides

To update individual properties at runtime without reinitializing the SDK, use setConfigurableItem(_:value:):

ConnectSDK.shared.setConfigurableItem("CaptureScreenVisits", value: true)

Examples

Disable layout capture on a specific screen:

ConnectSDK.shared.setConfigurableItem("CaptureLayoutOn", value: 0)

Increase the capture delay to 1000 milliseconds:

ConnectSDK.shared.setConfigurableItem("CaptureLayoutDelay", value: 1000)

Disable deduplication of repeated SwiftUI view captures:

ConnectSDK.shared.setConfigurableItem("RemoveSwiftUIDuplicates", value: false)

Enable full request and response payload logging (useful for debugging; disable in production):

ConnectSDK.shared.setConfigurableItem("LogFullRequestResponsePayloads", value: true)
📘

Note

Runtime overrides apply immediately and persist for the session. They do not affect the configuration passed at initialization.