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.

fromPlistwithCollectorwithLocalConfiguration
IdentityAppKey from Sophonz-Info.plistapp key passed as an argumentnone
UploadOTLP/JSON to the collectorthe sameNone is created
Remote configUsedUsedNot used; implement SophonzConfigurable
otelOptionalOptionalRequired

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

FieldTypeDefault
ingestSophonzIngest?Filled by fromPlist / withCollector
appIdString?Legacy withAppId only
platformSophonzPlatform.default
endpointsSophonzEndpoints?Derived from the collector URL
captureServicesCaptureServicesOptions.default()
crashReporterCrashReporter.sophonz
logLevelSophonzLogLevel.default
otelOTelOptions?nil
runtimeConfigurationSophonzConfigurable?Only meaningful under withLocalConfiguration

SophonzIngest

FieldSent asPlist key
collectorUrl—CollectorURL
appKeyservice.keyAppKey
appNameservice.nameAppName
projectservice.namespaceProject
deploymentEnvironmentdeployment.environment.nameDeploymentEnvironment

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

FieldTypeDefault
resourceResource?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(...).

MethodTarget
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

FieldTypeDefault
ignoredURLs[String][] — matched as a substring
traceparent.onlyAllowDomains[String]?nil — no restriction
requestsDataSourceURLSessionRequestsDataSource?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

FieldTypeDefault
instrumentVisibilityBooltrue
instrumentFirstRenderBooltrue
viewControllerBlockList.types[AnyClass][]
viewControllerBlockList.names[String][] — uppercased substring match
viewControllerBlockList.blockHostingControllersBooltrue

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

FieldTypeDefault
captureTapCoordinatesBooltrue
ignoredViewTypes[AnyClass][]
tapPhase.onStart, .onEnd.onStart
delegateTapCaptureServiceDelegate?nil

Keyboard views are excluded automatically.

WebView

FieldTypeDefault
stripQueryParamsBoolfalse
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

FieldTypeDefault
captureDataBoolfalse

Hang detection

Instead of an options struct it takes HangLimits, which is overwritten from remote config at start.

SettingDefault
Hang threshold0.249s
Maximum per session20
Sampling trigger threshold0.15s
Sampling interval0.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