Configuration
Every field of Sophonz.Options, the capture service builder, per-service options, and the current state of the delivery path.
Configuration is the single Sophonz.Options value passed to Sophonz.start(options:). The only thing changeable after start is the log level, so everything else has to be decided up front.
Start modes
There are three public ways to build Options, and they are mutually exclusive.
fromPlist | withCollector | withLocalConfiguration | |
|---|---|---|---|
| Identity | AppKey from Sophonz-Info.plist | app key passed as an argument | none |
| Upload | OTLP/JSON to the collector | the same | None is created |
| Remote config | Used | Used | Not used; implement SophonzConfigurable |
otel | Optional | Optional | Required |
fromPlist returns nil when the file is missing or names no collector and key. That is a build to leave unstarted rather than start blind.
CAUTION — withAppId is legacy
The Embrace-lineage path with a 5-character appId still exists. Its default endpoints are derived on the .invalid domain (RFC 2606), so they reach nothing, and there is no way to send an app key through it. Do not use it in new code.
Sophonz.Options
| Field | Type | Default |
|---|---|---|
ingest | SophonzIngest? | Filled by fromPlist / withCollector |
appId | String? | Legacy withAppId only |
platform | SophonzPlatform | .default |
endpoints | SophonzEndpoints? | Derived from the collector URL |
captureServices | CaptureServicesOptions | .default() |
crashReporter | CrashReporter | .sophonz |
logLevel | SophonzLogLevel | .default |
otel | OTelOptions? | nil |
runtimeConfiguration | SophonzConfigurable? | Only meaningful under withLocalConfiguration |
SophonzIngest
| Field | Sent as | Plist key |
|---|---|---|
collectorUrl | — | CollectorURL |
appKey | service.key | AppKey |
appName | service.name | AppName |
project | service.namespace | Project |
deploymentEnvironment | deployment.environment.name | DeploymentEnvironment |
appName overrides the default derived from the bundle (<bundleId>:<processName>). The portal matches an app on (project, service.name), so a value other than the registered name means the data arrives and the app's page stays empty.
The delivery path
Payloads go to /v1/traces and /v1/logs under the collector URL as gzipped OTLP/JSON; attachments go to /v2/attachments. The app key travels as the service.key resource attribute, the same shape the Android SDK sends.
Transcoding happens at send time. Storage keeps the SDK's own format, so storage prioritisation, crash resurrection and retry all keep working on the stored shape.
Uploads happen when a session part ends — when the app backgrounds, or on the next launch after a kill. There is no periodic timer, so an app that stays in the foreground sends nothing while it does.
NOTE — An unregistered key is dropped silently
The collector runs service_key_mode: enforce. A missing or unresolvable key means the telemetry is discarded without an error, so a misconfigured build looks like it is working and produces nothing.
The SDK's own uploads are excluded from network capture. Otherwise every upload would produce a span for /v1/traces, that span would travel in the next upload, and that upload would produce another.
To send somewhere other than a Sophonz collector, start with withLocalConfiguration and supply exporters.
let otel = Sophonz.OTelOptions(
spanExporters: [myOtlpSpanExporter],
logExporters: [myOtlpLogExporter]
)
try Sophonz.start(options: .withLocalConfiguration(otel: otel))OTelOptions
| Field | Type | Default |
|---|---|---|
resource | Resource? | nil |
spanProcessors | [SpanProcessor] | [] |
spanExporters | [SpanExporter] | [] |
logProcessors | [LogRecordProcessor] | [] |
logExporters | [LogRecordExporter] | [] |
service.name, service.version, and telemetry.sdk.language are always set by the SDK and cannot be overridden through resource.
Choosing capture services
To keep the default list, pass nothing. To adjust it, use the builder.
let services = Sophonz.CaptureServicesOptionsBuilder()
.addDefaults()
.addHangCaptureService()
.build()
try Sophonz.start(options: .withCollector(
url: "https://in.sophonz.ai",
appKey: "sk_…",
captureServices: services
))CAUTION — The builder starts empty
Without addDefaults() no default service is installed at all. If the intent was to drop just one, call addDefaults() and then remove(...).
| Method | Target |
|---|---|
addDefaults() | The six defaults (not hang or push notification) |
addUrlSessionCaptureService(withOptions:) | Network |
addViewCaptureService(withOptions:) | Screens |
addTapCaptureService(withOptions:) | Taps |
addWebViewCaptureService(withOptions:) | WebView |
addLowMemoryWarningCaptureService() | Memory warnings |
addLowPowerModeCaptureService() | Low power mode |
addHangCaptureService() | Hang detection |
addPushNotificationCaptureService(withOptions:) | Push notifications |
add(_:) | A service of your own |
remove(ofType:), remove(sophonzType:) | Removal |
Per-service options
Network
| Field | Type | Default |
|---|---|---|
ignoredURLs | [String] | [] — matched as a substring |
traceparent.onlyAllowDomains | [String]? | nil — no restriction |
requestsDataSource | URLSessionRequestsDataSource? | nil |
Setting onlyAllowDomains to an empty array attaches traceparent to nothing. Entries must be bare hostnames: anything containing / or whitespace, or starting with a dot, is dropped with a warning rather than an error — so write them precisely or the filter silently does not apply.
Screens
| Field | Type | Default |
|---|---|---|
instrumentVisibility | Bool | true |
instrumentFirstRender | Bool | true |
viewControllerBlockList.types | [AnyClass] | [] |
viewControllerBlockList.names | [String] | [] — uppercased substring match |
viewControllerBlockList.blockHostingControllers | Bool | true |
NOTE — SwiftUI screens are excluded by default
Because blockHostingControllers is true, UIHostingController and its children are left out of screen capture. To instrument SwiftUI screens, turn it off or use the sophonzTrace(_:) view modifier.
instrumentFirstRender is evaluated together with remote config. Enabling it locally has no effect if it is disabled remotely.
Taps
| Field | Type | Default |
|---|---|---|
captureTapCoordinates | Bool | true |
ignoredViewTypes | [AnyClass] | [] |
tapPhase | .onStart, .onEnd | .onStart |
delegate | TapCaptureServiceDelegate? | nil |
Keyboard views are excluded automatically.
WebView
| Field | Type | Default |
|---|---|---|
stripQueryParams | Bool | false |
fragmentHandling | .keep, .redact, .remove | .keep |
.redact clears only key=value pairs inside the fragment, keeping hash routes and short anchors. It works independently of the query-parameter setting.
Push notifications
| Field | Type | Default |
|---|---|---|
captureData | Bool | false |
Hang detection
Instead of an options struct it takes HangLimits, which is overwritten from remote config at start.
| Setting | Default |
|---|---|
| Hang threshold | 0.249s |
| Maximum per session | 20 |
| Sampling trigger threshold | 0.15s |
| Sampling interval | 0.05s |
Log level
The only value changeable after start. It controls the SDK's own console output, not the logs it collects.
Sophonz.shared.logLevel = .debug