ConnectConfig

A typed configuration object passed to ConnectSDK.shared.enable(with:). ConnectConfig is the entry point for all Connect SDK initialization in Swift — it carries credentials, push configuration, layout capture rules, UI behavior, logging, network options, and an escape hatch for raw configuration keys.

Platform: iOS 15.1+
Language: Swift
Isolation: @MainActor (the enable(with:) call site)
Declared in: ConnectSDK

ConnectConfig conforms to @unchecked Sendable, so it can be passed across actor boundaries in Swift 6 strict concurrency contexts.


Initializer

public struct ConnectConfig : @unchecked Sendable {
    public let appKey: String
    public let postURL: String
    public var push: ConnectPushConfig
    public var layout: ConnectConfig.Layout
    public var ui: ConnectConfig.UI
    public var logging: ConnectConfig.Logging
    public var network: ConnectConfig.Network
    public var advanced: [ConnectConfig.AdvancedKey: Any]

    public init(
        appKey: String,
        postURL: String,
        push: ConnectPushConfig = .off,
        layout: ConnectConfig.Layout = .loadFromBundle(),
        ui: ConnectConfig.UI = UI(),
        logging: ConnectConfig.Logging = Logging(),
        network: ConnectConfig.Network = Network(),
        advanced: [ConnectConfig.AdvancedKey: Any] = [:]
    )
}

appKey and postURL are immutable after initialization. The remaining properties are mutable, so you can adjust them on a ConnectConfig value before passing it to enable(with:).

Parameters

ParameterTypeDefaultDescription
appKeyStringRequiredYour Acoustic Connect app key.
postURLStringRequiredThe Connect collector endpoint URL.
pushConnectPushConfig.offPush notification mode and App Group identifier. See ConnectPush.
layoutLayout.loadFromBundle()AutoLayout and map ID configuration. See ConnectConfig.Layout.
uiUIUI()SwiftUI capture behavior. See ConnectConfig.UI.
loggingLoggingLogging()Payload logging and location options. See ConnectConfig.Logging.
networkNetworkNetwork()POST timeout, caching, and compression. See ConnectConfig.Network.
advanced[AdvancedKey: Any][:]Escape hatch for raw configuration keys. See ConnectConfig.AdvancedKey.

Example

let config = ConnectConfig(
    appKey: "YOUR_APP_KEY",
    postURL: "https://collector.example.com/collectorPost",
    push: ConnectPushConfig(mode: .automatic, appGroupIdentifier: "group.com.example.YourApp"),
    network: ConnectConfig.Network(postTimeoutSeconds: 30, compressPayloads: true),
    advanced: [.sessionTimeout: 300]
)
ConnectSDK.shared.enable(with: config)

For integration steps, see Integrate the Connect SDK into a native iOS app (Swift).


ConnectConfig.Layout

Controls AutoLayout capture and map ID configuration. For the full schema of the autoLayout dictionary, see Configure data capture settings in a native iOS app.

PropertyTypeDefaultDescription
autoLayout[AnyHashable: Any]?From bundleAutoLayout capture configuration dictionary.
appendMapIds[AnyHashable: Any]?From bundleMap ID append configuration dictionary.

Static helpers

HelperDescription
.loadFromBundle()Reads configuration from ConnectLayoutConfig.json inside the framework-bundled ConnectResources.bundle. This is the default. Falls back to .basicAnalytics if the file is absent.
.basicAnalyticsMinimal layout configuration sufficient for basic analytics. Used automatically when ConnectLayoutConfig.json is not found in the bundle.
.noneDisables layout configuration entirely.

To customize layout configuration at initialization, pass an inline dictionary to Layout(autoLayout:appendMapIds:):

let layoutConfig: [AnyHashable: Any] = [
    "AutoLayout": [
        "GlobalScreenSettings": [
            "CaptureUserEvents": true,
            "ScreenChange": true,
            "ScreenShot": true,
            "CaptureLayoutOn": 2,
            "CaptureScreenshotOn": 2
        ]
    ]
]

let config = ConnectConfig(
    appKey: "YOUR_APP_KEY",
    postURL: "https://collector.example.com/collectorPost",
    layout: ConnectConfig.Layout(autoLayout: layoutConfig)
)

ConnectConfig.UI

Controls SwiftUI-specific capture behavior.

PropertyTypeDefaultDescription
removeSwiftUIDuplicatesBooltrueDeduplicates repeated SwiftUI view captures.
captureKeyboardTouchesBoolfalseCaptures touches on the system keyboard.
captureSwiftUINonVariadicBooltrueUses the non-variadic SwiftUI capture path.

ConnectConfig.Logging

Controls what the SDK writes to the console and whether location events are captured.

PropertyTypeDefaultDescription
logFullPayloadsBoolfalseLogs full HTTP request and response payloads to the console. Useful for debugging — disable in production.
logLocationEnabledBoolfalseLogs location updates. Requires the app to have location permission from the user.

ConnectConfig.Network

Controls network behavior for outgoing SDK payloads.

PropertyTypeDefaultDescription
postTimeoutSecondsTimeInterval?nilPOST request timeout in seconds. nil uses the bundle default.
cachingLevelInt?nilOffline caching level. nil uses the bundle default.
compressPayloadsBooltrueGzip-compresses outgoing payloads.

ConnectConfig.AdvancedKey

An escape hatch for raw configuration keys not covered by the typed API. Pass values in the advanced dictionary at initialization. AdvancedKey conforms to RawRepresentable, Hashable, and Sendable.

KeyRaw valueDescription
.killSwitchURL"KillSwitchUrl"Remote kill-switch endpoint URL.
.sessionTimeout"SessionTimeout"Inactivity timeout in seconds before a new session starts.
.manualPostEnabled"ManualPostEnabled"Enables ConnectSDK.shared.requestManualPost().
.dynamicConfigEnabled"DynamicConfigurationEnabled"Enables remote configuration fetching.
.maxBytesPerActivation"MaxNumberOfBytesPerActivation"Maximum payload bytes per app activation.
.maxPostsPerActivation"MaxNumberOfPostsPerActivation"Maximum POST requests per app activation.
.postIntervalSeconds"PostMessageTimeIntervals"Interval in seconds between automatic POSTs.
.maxPostBytesSize"PostMessageMaxBytesSize"Maximum bytes per individual POST.

For keys not listed above, construct a custom AdvancedKey:

let config = ConnectConfig(
    appKey: "YOUR_APP_KEY",
    postURL: "https://collector.example.com/collectorPost",
    advanced: [AdvancedKey("YourRawKeyName"): yourValue]
)