ConnectConfig

A typed configuration object passed to ConnectSDK.shared.enable(with:). Use ConnectConfig when you need more control than the convenience enable(appKey:postURL:push:) method provides.

Platform: iOS 15.1+
Declared in: ConnectSDK


Initializer

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

Parameters

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

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)

ConnectConfig.Layout

Controls AutoLayout capture and map ID configuration.

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 in the main 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.

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 logs 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.

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, use a custom AdvancedKey:

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