Skip to content

Swift API (iOS)

import QuameleonQACore
Call Notes
startProduction(config:adapter:sdkVersion:) -> String? Starts production mode and installs capture (main thread). Returns the cached remote config JSON, or nil when not started.
prepare() Collects device and app context; called by startProduction and QuameleonNative.start
install() Installs capture after a QA activation (idempotent, main thread)
markSensitive(_ view:) / unmarkSensitive(_ view:) Masks a view and its subtree (weak reference)
QuameleonProductionConfig(
apiKey: String,
endpoint: String,
directory: URL = QuameleonProductionConfig.defaultDirectory, // Application Support/quameleon_prod
publicKeyPem: String? = nil,
sampleRate: Double = 1.0,
uploadIntervalMs: Int = 30_000,
otlpEndpoint: String? = nil,
otlpHeaders: [String: String] = [:],
crashlytics: Bool = false,
deviceId: String? = nil, // SDK 0.5: your own device id instead of the persisted per-install one
replaySampleRate: Double? = nil // SDK 0.5: local default; remote `replay.sample_rate` wins
)

QuameleonProductionConfig.fromJson(_:directory:) reads the snake_case JSON form. deviceId and replay sampling mirror the JavaScript config.

Call Notes
isActive, isProduction Mode state
emit(kind:name:propsJson:actionId:) Emits a signal; props as typed JSON
screen(name:route:props:) screen signal
configure(json:) Capture categories as JSON
logException(_ error:props:), logException(_ exception:props:) Handled Error or NSException
setFeatureFlag(name:variant:) context flag.<name>
startSpan(name:parent:attributes:) Returns a QuameleonSpan (setAttribute, addEvent, recordException, end(status:))
setAppInfo(json:) Late app fields
captureScreenshot(reason:) A masked screenshot frame
flush(timeout:) Waits until queued signals are written
stop() Stops capture
Call Notes
identify(_ distinctId: String, properties: [String: Any]? = nil) Same behavior as the JavaScript identify; properties are plain Swift values
identify(_ distinctId: String, propsJson: String?) The same, with properties as typed JSON
reset() Forgets the distinct id (log out); in production also starts a new session and user session
capture(_ event: String, propsJson: String? = nil) Alias of emit(kind: "event", name: event, propsJson:)
QuameleonCore.shared.identify("user-123", properties: ["plan": "pro"])
QuameleonCore.shared.capture("order.placed", propsJson: #"{"items":{"t":"int","v":2},"currency":{"t":"string","v":"EUR"}}"#)

Typed JSON props are flat {"<key>": {"t": T, "v": V}} with T one of string, int, float, bool, null ("str" is not a type).

QuameleonNative.start(adapter:sdkVersion:) -> Bool reads -quameleon_token, -quameleon_port and -quameleon_token_expires from the launch arguments and activates the core when the token is valid.

Modifier Effect
.quameleonScreen(_ name:) screen signal on appear
.quameleonID(_ id:) Sets the accessibility identifier used as tap target and hierarchy id
.quameleonSensitive() Masks the view in replay and screenshots
Call Notes
QuameleonWebView.attach(_:allowedOrigins:) Injects qa-web into a WKWebView
QuameleonPush.installDelegateProxy() push signals from the notification center delegate