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
| Parameter | Type | Default | Description |
|---|---|---|---|
appKey | String | Required | Your Acoustic Connect app key. |
postURL | String | Required | The Connect collector endpoint URL. |
push | ConnectPushConfig | .off | Push notification mode and App Group identifier. See ConnectPush. |
layout | Layout | .loadFromBundle() | AutoLayout and map ID configuration. See ConnectConfig.Layout. |
ui | UI | UI() | SwiftUI capture behavior. See ConnectConfig.UI. |
logging | Logging | Logging() | Payload logging and location options. See ConnectConfig.Logging. |
network | Network | Network() | 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.
| Property | Type | Default | Description |
|---|---|---|---|
autoLayout | [AnyHashable: Any]? | From bundle | AutoLayout capture configuration dictionary. |
appendMapIds | [AnyHashable: Any]? | From bundle | Map ID append configuration dictionary. |
Static helpers
| Helper | Description |
|---|---|
.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. |
.basicAnalytics | Minimal layout configuration sufficient for basic analytics. Used automatically when ConnectLayoutConfig.json is not found in the bundle. |
.none | Disables 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.
| Property | Type | Default | Description |
|---|---|---|---|
removeSwiftUIDuplicates | Bool | true | Deduplicates repeated SwiftUI view captures. |
captureKeyboardTouches | Bool | false | Captures touches on the system keyboard. |
captureSwiftUINonVariadic | Bool | true | Uses the non-variadic SwiftUI capture path. |
ConnectConfig.Logging
Controls what the SDK writes to the console and whether location events are captured.
| Property | Type | Default | Description |
|---|---|---|---|
logFullPayloads | Bool | false | Logs full HTTP request and response payloads to the console. Useful for debugging — disable in production. |
logLocationEnabled | Bool | false | Logs location updates. Requires the app to have location permission from the user. |
ConnectConfig.Network
Controls network behavior for outgoing SDK payloads.
| Property | Type | Default | Description |
|---|---|---|---|
postTimeoutSeconds | TimeInterval? | nil | POST request timeout in seconds. nil uses the bundle default. |
cachingLevel | Int? | nil | Offline caching level. nil uses the bundle default. |
compressPayloads | Bool | true | Gzip-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.
| Key | Raw value | Description |
|---|---|---|
.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]
)Updated 17 days ago
