expo-observe / expo-app-metrics: build-time opt-out (disabled until configured) and a switch for crash capture
Bertac
What we need
- A build-time way to start with dispatching disabled: a config plugin option, or an Info.plist / AndroidManifest key the native side reads before JS runs. Dispatching would turn on only when the app calls configure at runtime.
- A way to turn crash capture off, at build time or through the same configuration: the JVM handler on Android and the MetricKit crash diagnostics on iOS.
- On Android, install the OkHttp client hook only when network tracing is enabled.
Why
Our app sends usage data only after the user consents. With expo-observe 58.0.19 and expo-app-metrics 58.0.15, a fresh install can send and collect data before any JS runs, so before the app can ask for consent:
- Dispatching defaults to on when no configuration is stored: ObservabilityManager.kt:389 (config?.dispatchingEnabled ?: true) and Observability.swift:385 (config?.dispatchingEnabled ?? true).
- The configuration comes only from the JS configure call. It is persisted (UserDefaults / SharedPreferences). Neither package has an app.plugin.js, and we found no plist or manifest key that the native code reads.
- On iOS, ObserveAppDelegateSubscriber.applicationWillResignActive (ObserveAppDelegateSubscriber.swift:7) triggers a dispatch independently of JS.
- Crash capture has no off switch. Android: JvmCrashHandler.install runs unconditionally in AppMetricsApplicationLifecycleListeners.kt:19. iOS: the MetricKit subscriber is registered at launch, and crashDiagnostics is mapped to crash reports (MetricKitSubscriber.swift:31).
- Android: OkHttpClientProviderHook.installIfNeeded() (AppMetricsApplicationLifecycleListeners.kt:28) is installed unconditionally. networkTraces: false stops the recording but leaves the hook in place.
Patching the native defaults locally would work today, but every SDK upgrade could silently undo it. A supported opt-out would let apps with a consent requirement adopt these packages.
Environment: Expo SDK 58 (expo 58.0.22, expo-observe 58.0.19, expo-app-metrics 58.0.15), iOS and Android, Continuous Native Generation (expo prebuild, native folders not committed).