Configuration
The native configuration a Flutter app needs on each platform — sophonz-config.json and Sophonz-Info.plist — how service identity works, and every option available from Dart.
Where the data goes and which service it belongs to is native configuration: sophonz-config.json on Android, Sophonz-Info.plist on iOS. Neither can be set from Dart. The Dart side only decides what the Flutter layer captures and how routes are timed.
At a glance
| Setting | Android (sophonz-config.json) | iOS (Sophonz-Info.plist) |
|---|---|---|
| Collector URL | sdk_config.ingest.collector_url | CollectorURL |
| Service key | sdk_config.ingest.service_key | AppKey |
| Service name | the application ID | AppName |
| Project | sdk_config.ingest.service_namespace | Project |
| Environment | sdk_config.ingest.deployment_environment | DeploymentEnvironment |
| Framework | sdk_config.app_framework: "flutter" | fromPlist(platform: .flutter) |
| Read at | build time, by the Gradle plugin | launch, by Sophonz.Options.fromPlist |
Service identity
Every span and log carries resource attributes that say which service it belongs to.
| Resource attribute | Meaning |
|---|---|
service.key | The service key. The collector resolves the tenant and app from it |
service.name | The app's name. On Android it is the application ID; on iOS AppName, or <bundle ID>:<process name> without it |
service.namespace | The project |
deployment.environment.name | The environment, such as production or staging |
Use the same service key and project on both platforms if the Android and iOS builds should appear as one app.
WARNING — No service key, no data
The collector runs with the service key enforced. Telemetry with a missing or unregistered key is dropped without an error. The app starts, captures and uploads normally, and nothing appears in Sophonz. When data is missing on one platform, check that platform's key first.
To separate environments, keep one service key per app and change deployment_environment / DeploymentEnvironment per build, as shown below for each platform.
Android
sophonz-config.json
Create the file in the app module. The Gradle plugin builds it into the SDK, so a change needs a rebuild.
{
"sdk_config": {
"app_framework": "flutter",
"ingest": {
"collector_url": "https://in.sophonz.ai",
"service_key": "sk_replace_me",
"service_namespace": "my-project",
"deployment_environment": "production"
}
}
}| Key | Default | Effect |
|---|---|---|
sdk_config.app_framework | unset | Set to flutter so the SDK reports the app as a Flutter app |
sdk_config.ingest.collector_url | https://in.sophonz.ai | Base URL of the collector. The SDK appends /v1/traces and /v1/logs |
sdk_config.ingest.service_key | none | Sent as service.key. Without it nothing is accepted |
sdk_config.ingest.service_namespace | none | Sent as service.namespace |
sdk_config.ingest.deployment_environment | none | Sent as deployment.environment.name |
ndk_enabled | true | Native (C/C++) crash capture. The Flutter engine is native code, so leave it on |
app_id, api_token | none | Mapping file upload credentials, not telemetry credentials. See Release builds |
The Android SDK's capture toggles (ANR, WebView, taps, network) use the same file. They are listed in the Android configuration reference.
CAUTION — Unknown keys fail the build
The parser rejects keys it does not recognise. A typo stops the build, so only use keys from this page or the Android configuration reference.
Per build type or flavor
The file is looked up in this order, and the first match wins: src/<variant>/, flavor combinations, individual flavors, src/<build type>/, then src/main/. A debug build can therefore report a different environment:
{
"sdk_config": {
"app_framework": "flutter",
"ingest": {
"service_key": "sk_replace_me",
"service_namespace": "my-project",
"deployment_environment": "development"
}
}
}With flutter build apk --flavor staging, a file in android/app/src/staging/ is used.
Keeping the key out of the repository
collector_url and service_key can come from environment variables at build time:
SOPHONZ_SERVICE_KEY=sk_... flutter build appbundle --release| Variable | Replaces |
|---|---|
SOPHONZ_SERVICE_KEY | sdk_config.ingest.service_key |
SOPHONZ_COLLECTOR_URL | sdk_config.ingest.collector_url |
A value in the file wins over the variable, so leave the key out of the file when using this.
iOS
Sophonz-Info.plist
Create ios/Sophonz-Info.plist and add it to the Runner target in Xcode (File > Add Files to "Runner", Runner target checked). It must end up in the app bundle as a resource.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CollectorURL</key>
<string>https://in.sophonz.ai</string>
<key>AppKey</key>
<string>sk_replace_me</string>
<key>Project</key>
<string>my-project</string>
<key>DeploymentEnvironment</key>
<string>production</string>
</dict>
</plist>| Key | Required | Effect |
|---|---|---|
CollectorURL | yes | Base URL of the collector. Do not append /v1/... |
AppKey | yes | The service key, sent as service.key |
AppName | no | Sent as service.name. Without it the name is <bundle ID>:<process name> |
Project | no | Sent as service.namespace |
DeploymentEnvironment | no | Sent as deployment.environment.name. Defaults to production |
CAUTION — An unconfigured plist starts nothing
Sophonz.Options.fromPlist returns nil when CollectorURL or AppKey is missing or empty. A value that still reads $(SOMETHING) counts as missing: Xcode expands build settings only in the target's Info.plist, never in a plist copied as a resource. Put literal values in this file, or generate it in a build phase before Copy Bundle Resources.
NOTE — AppName needs a newer Apple SDK
AppName is read by Apple SDK builds after 1.0.0. With 1.0.0 the key is ignored and the service name is the bundle-derived default. The portal matches an app on project and service.name, so changing the name later detaches the data from the app's existing page.
Start options
fromPlist takes the other start options as arguments.
let captureServices = CaptureServicesOptionsBuilder()
.addDefaults()
.addPushNotificationCaptureService(withOptions: .init())
.build()
if let options = Sophonz.Options.fromPlist(
platform: .flutter,
captureServices: captureServices,
crashReporter: .sophonz,
logLevel: .default
) {
try? Sophonz.start(options: options)
}| Argument | Default | Notes |
|---|---|---|
platform | .native | Pass .flutter |
captureServices | .default() | Push notification capture is not in the defaults; add it as above. The full list is in iOS instrumentation |
crashReporter | .sophonz | .none to disable crash capture |
logLevel | .default | Console verbosity of the SDK itself |
otel | nil | Sophonz.OTelOptions with your own exporters. The only way to export elsewhere on iOS |
To configure in code instead of a plist, use Sophonz.Options.withCollector(url:appKey:project:deploymentEnvironment:platform:). That is also the way to pick values per build configuration without a generated plist, for example by reading them from the target's Info.plist, where $(...) is expanded.
Dart
Dart has no collector or key setting. These are the options that exist.
| Option | Where | Default |
|---|---|---|
action | Sophonz.instance.start | none |
routeSettingsExtractor | SophonzNavigationObserver, SophonzGoRouterObserver | route.settings |
screenLoadConfig.recencyThreshold | both observers, through SophonzScreenLoadConfig | 1 second |
router | SophonzGoRouterObserver | none |
internalClient | SophonzHttpClient | a new http.Client() |
endpoint, headers, timeoutSeconds | addSpanExporter, addLogRecordExporter | native SDK timeout |
The slow-frame, frozen-frame and isolate-hang thresholds are fixed in 0.1.0 and cannot be changed. Their values are in Instrumentation.
start
await Sophonz.instance.start(action: () => runApp(const MyApp()));With action, start wraps FlutterError.onError (keeping the previous handler and calling it after recording), sets PlatformDispatcher.instance.onError, then runs action. Without action, no error handlers are installed; install them later:
await Sophonz.instance.start();
await Sophonz.instance.installErrorHandlers(() => runApp(const MyApp()));CAUTION — PlatformDispatcher.onError is replaced, not chained
FlutterError.onError keeps your earlier handler, but PlatformDispatcher.instance.onError is overwritten. Set your own PlatformDispatcher handler before start and it no longer runs; set it after and Sophonz stops receiving those errors. If you need both, set yours after start and call Sophonz.instance.logDartError(error, stack) from it.
Navigation
SophonzNavigationObserver(
routeSettingsExtractor: (route) => route.settings,
screenLoadConfig: const SophonzScreenLoadConfig(
recencyThreshold: Duration(milliseconds: 500),
),
)| Option | Effect |
|---|---|
routeSettingsExtractor | Returns the RouteSettings whose name is recorded. Return null to skip a route |
screenLoadConfig.recencyThreshold | How recent a touch must be to count as the start of a screen load. An older touch falls back to the push time |
Route naming, go_router and what each observer records are covered in Navigation.
Additional exporters (Android only)
Sophonz.instance.addSpanExporter(
endpoint: 'https://otlp.example.com/v1/traces',
headers: [{'x-api-key': 'token'}],
timeoutSeconds: 10,
);
Sophonz.instance.addLogRecordExporter(
endpoint: 'https://otlp.example.com/v1/logs',
);
await Sophonz.instance.start(action: () => runApp(const MyApp()));| Parameter | Notes |
|---|---|
endpoint | The full OTLP/HTTP URL including /v1/traces or /v1/logs. An empty string is ignored |
headers | A list of single-entry maps, one per header |
timeoutSeconds | Export timeout. The native default when omitted |
These export in addition to Sophonz, not instead of it.
CAUTION — Exporters must reach the native SDK before it starts
Exporters are queued in Dart and forwarded when start() runs. A call after start() is ignored. If Application.onCreate() already started the Android SDK, the forwarded exporters arrive too late and are ignored as well, so using both means giving up startup timing or registering the exporter in Kotlin before Sophonz.start(this). On iOS they are never forwarded; use otel: in the start options.
Next
- Instrumentation — what each layer captures automatically
- Release builds — mapping files and dSYMs for readable stack traces