Skip to content

Kotlin API (Android)

Packages: dev.qualgent.quameleon.qa.core (pure JVM) and dev.qualgent.quameleon.qa.platform (Android).

Call Notes
startProduction(app, config, adapter = "native", current = null): String? Starts production mode and installs capture. Returns the cached remote config JSON, or null when not started.
productionDir(ctx): File <filesDir>/quameleon_prod, the default spool directory
install(app, currentActivity) Installs capture after QuameleonQaActivation.activate(...) succeeds
markSensitive(view) / unmarkSensitive(view) Masks a view and its subtree (weak reference)
idResolver: (View) -> String? Maps a view to its test id. Default: resource entry name, else contentDescription
uninstall() Removes hooks
Call Notes
activate(activity, adapter = "native"): Boolean QA activation from the launch intent. Refuses unless the build is debuggable or has QA_ACTIVATION=true (false always wins), and Settings.Global quameleon_qa_token holds the host’s v1:<sha256(token)>:<expires> commitment (written by adb shell settings put global; quameleon-qa does it)
prepare(ctx) Wires QuameleonCore.qaActivationAllowed / qaProvisioning for adapters that call QuameleonCore.activate themselves
allowed(ctx): Boolean The manifest / debuggable rule alone
data class ProductionConfig(
val apiKey: String,
val endpoint: String,
val dir: File,
val publicKeyPem: String? = null,
val sampleRate: Double = 1.0,
val uploadIntervalMs: Long = 30_000,
val otlpEndpoint: String? = null,
val otlpHeaders: Map<String, String> = emptyMap(),
val crashlytics: Boolean = false,
val deviceId: String? = null, // 0.5: your own install id (≤ 128 chars), else a persisted UUID
val replaySampleRate: Double? = null, // 0.5: local default; remote config replay.sample_rate wins
)

ProductionConfig.fromJson(json, dir) reads the snake_case form used by the React Native bridge and config files. See Configuration options.

Call Notes
isActive QA or production mode running
emit(kind, name, propsJson?, actionId?) Emits a signal; props as typed JSON, for example {"items":{"t":"int","v":2}}
screen(name, route?, propsJson?) screen signal
configure(json) Capture categories as JSON
logException(throwable, propsJson?) Handled error
setAppInfo(json) Late app fields (update_id, bundle_hash, …)
captureScreenshot(reason) A masked screenshot frame
flush(timeoutMs) Waits until queued signals are written
activate(token, port, adapter, deviceJson, appJson, processStartNs) QA mode only
probeHandler, resolveProbe(id, valueJson?, error?) QA probes
stop() Stops capture
Call Notes
identify(id, propsJson?) Persists id as the device’s distinct_id (1 to 200 characters) and emits context user.id, plus context person when propsJson is given. propsJson is a plain JSON object, for example {"plan":"pro"}; secret-looking keys are redacted.
reset() Clears distinct_id and emits context user.id null; in production also starts a new session and user session
capture(event, propsJson?) Alias of emit("event", event, propsJson); props are typed JSON
deviceId() The current device_id
Call Notes
QuameleonOkHttp.instrument(client) Returns a client with the interceptor and timing EventListener
QuameleonOkHttp.interceptor() Interceptor only
QuameleonOkHttp.eventListenerFactory(delegate?) DNS, connect, TLS, TTFB phases; chains your factory
network_huc config key HttpURLConnection capture (opt-in)
Call Notes
QuameleonScreens.trackNavController(navController) Reports androidx.navigation destinations (label, else route) as screens; call once per NavController
QuameleonWebView.attach(webView, allowedOrigins, client?) Injects qa-web before the first load. Page messages need androidx.webkit:webkit 1.3+ in the app (WebView 83+): only the allowlisted main frame is trusted; without it the WebView stays fully masked and sends no page signals
QuameleonPush.received(id, source, title?, body?) / opened(...) push signals

QuameleonSpans.start(name, parent?) returns a QuameleonSpan with W3C ids, mirroring the JavaScript startSpan.