11 - DevTools
Concept
1. Why
Developers and QA testers need to see inside a running app on a real device: the requests it sent, the errors it hit, what it stored. They also need to force the hard cases: an expired token, a failing backend, another API host. External tools need a computer and a cable. A tester in the field has neither.
So apps grow an in-app developer dashboard behind a floating button. That's useful, and dangerous if done carelessly:
- A dashboard that ships in an installable production build, even a profile build, can show a user's refresh token and copy it to the clipboard.
- A network monitor that records request bodies holds passwords and one-time codes in memory, ready to be copied into a bug report.
sinew_devtools provides the dashboard as a reusable mechanism, with those risks designed out:
- it's compiled out of production builds;
- it redacts when recording, not when displaying;
- it masks secrets and never copies them;
- it asks before anything destructive.
It ships in 1.0, as the last milestone before the release.
2. Shape
Capture and UI, split
| Package | Holds | Why separate |
|---|---|---|
sinew_devtools | the entry contract, recorders, redaction, fault rules, host override | Capture works without the UI, for example to attach the last requests to a bug report. It has no UI toolkit dependency. |
sinew_devtools_ui | the entry contract (its pages are UI), the floating button, the dashboard, the built-in inspector pages, on each platform's Material toolkit | Developer UI isn't brand UI, so it doesn't depend on Camouflage. It uses its own theme and back stack, never the app's. |
sinew-devtools-noop (Kotlin) | the same public API as empty stubs | Release builds of Android depend on it instead, so no devtools code exists there |
The entry contract
DevToolSection(title: String, entries: List<DevToolEntry>)
DevToolEntry =
Page(name, description, icon, color, content, appBarActions = []) // opens a page
| Group(name, description, icon, color, children: List<DevToolEntry>) // opens a sub-list
| Toggle(name, description, icon, value: () -> Boolean, onChanged) // a switch shown inline
| Action(name, description, icon, confirm: String? = null, run) // runs on tap; confirm asks first
BuildRibbon(label: String) // "1.4.0 (212) · staging", in a corner of every screen
Sinew's built-in inspectors come in their own section. The app adds its own sections, with its own titles and entries: remote copy, analytics events, form playgrounds, its caches. Sinew predefines no app section.
SinewDevTools(
enabled = DevToolsGate.enabled, // a compile-time value, see Gating
sections = [ appSection("Product", [...]) ], // the built-in "Sinew" section is added first
ribbon = BuildRibbon("${version} · ${flavor}"),
redaction = Redaction.default + { fieldParts += ["cardnumber", "cvv"] },
) { App() }
Built-in inspectors
| Inspector | Kind | Fed by | Safety rule |
|---|---|---|---|
| Network Monitor | Page | the network recorder layer, plus cache serves the app reports | Redacted when recorded. Capped at 200 records. Cleared on sign-out. Copy and Copy as cURL give the redacted record; Replay sends it again through the app's client (see Copy and replay). |
| Exception Log | Page | a CrashReporter decorator, plus the platform's uncaught-error hooks | Capped at 50, with repeats within 2 seconds merged into one row with a count. Copy gives the redacted text only. |
| Key-Value Store | Page | KeyValueStore through InspectableStore | Values shown. Edit and delete ask for confirmation. |
| Secure Store | Page | SecureStore through InspectableStore | Values masked: the last 4 characters and the length (•••• 9f2c (412 chars)). Never copyable. "Clear all" asks for confirmation. |
| Local DB | Group | InspectableStores the app registers (one per DAO it wants visible) | Read-only. |
| Expire Access Token | Action | the auth layer | The next request goes out with an invalid token, so the real 401 → refresh path runs. Non-production only. |
| Fault Injection | Page | fault rules applied in the network stack | Rules live in memory only and are gone after a restart. See below. |
| API Host | Page | the hosts listed in the app's config | Never compiled into a production flavor. The active host shows in the ribbon. Only a listed host can be chosen; a remembered host the app no longer lists is forgotten. Requests for the client's own host move to the chosen base, keeping the path below the base path, after the auth layer attached the token. |
| Changelog | Page | text the app supplies |
Redaction, when recording
Redaction(
headers = { "Authorization", "Cookie", "Set-Cookie", "Proxy-Authorization" } + every name in each client's defaultHeaders,
fieldParts = { "password", "passwd", "token", "secret", "otp", "pin", "apikey", "credential", "signature" }, // matched inside normalized names
exactFields = { "code" }, // too short to match as a part
mask = "•••",
maxBodyBytes = 64 KB,
)
| Rule | Why |
|---|---|
| Redact before storing a record | Nothing sensitive exists in memory, so no screen, copy or export can leak it |
A key's name is normalized before matching: lowercased, with _, - and . removed. refreshToken, refresh_token and Refresh-Token all become refreshtoken. | Backends mix naming styles, and camelCase is the common one. Exact-name matching would record refreshToken in clear. |
A normalized name is redacted when it contains any of fieldParts (refreshtoken, newpassword, idtoken, xapikey all match), or equals one of exactFields | New fields that carry secrets are caught by their names, without updating a list |
| Matching runs at any depth of a JSON body, including objects inside arrays | A password nested in { "user": { "credentials": [ { "password": … } ] } } is still caught |
Every header the app sends through defaultHeaders is redacted automatically | Those are exactly the headers that carry API keys and device identifiers |
| Form bodies, query parameters and fragment parameters are redacted by the same field list, with names percent-decoded first | Tokens also travel as ?token=…, form fields, and an OAuth redirect's #access_token=… |
A body over maxBodyBytes is cut, with its real size shown | Large downloads don't fill memory |
| Binary bodies (images, files) are stored as type and size only | Nothing useful to read, and they can contain personal data |
| Cache records go through the same redaction | A cached response is still a response |
| An app extends the defaults, never replaces them wholesale | A custom list can't accidentally drop Authorization |
| A redacted text body says whether anything in it was hidden | The recorder needs it to decide whether a request can be replayed |
Recorders
| Recorder | Keeps | Cleared |
|---|---|---|
NetworkRecorder(capacity = 200) | method, URL, status, duration, redacted headers and bodies, error type and code, a "served from cache" marker, the client that sent it, whether it can be replayed, and whether it is a replay | on sign-out, on "Clear" in the page, on app restart |
ExceptionRecorder(capacity = 50, dedupeWindow = 2 s) | time, exception type, code, message key or server text, stack trace, repeat count | on "Clear", on app restart |
| Recording rule | Why |
|---|---|
| A repeat is merged when its type, code, message and source match a row last seen within the window, measured from that row's last occurrence, and the merged row moves to the top | A retry loop failing every second stays one row with a rising count, instead of filling the log |
An exception's message and stack trace (with its cause) go through Redaction.redactText: Bearer and Basic credentials, and name=value and JSON "name": value pairs whose names are sensitive | A plain error's message often carries the URL it failed on, ?token=… included |
| The network recorder takes the exchange before redaction and keeps only the redacted record | One place redacts, so no caller can store a raw value by mistake |
| A recording failure never stops the app's own handlers or the real crash reporter | Devtools must never change what the app does |
The recorders keep data in memory only and never write it to disk. The app's sign-out use case calls SinewDevTools.clearUserData(). In a build without devtools, that call does nothing.
DevToolsCrashReporter wraps the app's real reporter: CrashReporter.install(DevToolsCrashReporter(wrapping = realReporter)). Every report goes to the Exception Log and then on to the real reporter, unchanged.
Copy and replay
A tester checking data after a backend fix shouldn't have to walk the app back to that screen. So a record in the Network Monitor offers three actions:
| Action | What it gives | Rule |
|---|---|---|
| Copy | the record as text: method, URL, status, headers, bodies, timing | Exactly what was recorded, so every secret is still ••• |
| Copy as cURL | a curl command for the request | The same redacted values. A request that needs a token won't run as copied: it's for a bug report, not for running. |
| Replay | the same request, sent again through the app's own client | The rules below |
| Replay rule | Why |
|---|---|
It goes through the client that sent the original, so the auth layer adds a fresh token and the client adds its defaultHeaders | The token is never in the record, and never needs to be. Fault rules and the host override apply too, as for any request. |
Only a request where nothing else was hidden can be replayed: its URL, its own headers and its body kept everything. Authorization and the defaultHeaders don't count, since the client adds them again. | A login, an OTP check or a call with ?token= lost the secret it needs. Replaying ••• would send garbage. The page shows "Can't replay: a secret in it was hidden". |
| A cut body (over the cap) or a binary body can't be replayed | Only part of it, or only its type and size, was kept |
GET, HEAD and OPTIONS replay on tap. Anything else asks first: "Send POST /orders again? It may repeat what it did." | Replaying a payment or an order does it twice |
| A replay is a new record, marked as a replay, at the top of the list | The original stays, so the two responses can be compared |
| No editing before sending (Later) | Editing turns devtools into an API client and widens what a tester can do on a shared device |
| Replay exists only where devtools does | It's part of sinew_devtools, so the no-op build has none |
Fault injection
FaultRule(method: String? = null, pathPattern: String, status: Int? = null, delay: Duration? = null, drop: Boolean = false, body: String? = null)
| Rule | Why |
|---|---|
| Rules apply inside the auth layer | A forced 401 runs the real refresh path. A forced 503 on the refresh call previews the "backend down, session kept" screen; the refresh client needs the same hooks for that. |
A path pattern matches the end of the path, at a /, and * matches any run of characters | /orders catches /v1/orders without knowing the base path, and not /v1/myorders |
| When several rules match, the most recently added wins | A tester narrows a broad rule by adding a specific one |
| A dropped connection is classified as no connection, like a real one | The app shows its offline state, which is what a tester is checking |
| Rules are in memory only, gone after a restart | A rule forgotten on a test device can't break the next day's session |
| The ribbon shows "faults on" while any rule is active | A tester always knows the app is being lied to |
The overlay
| Rule | Why |
|---|---|
| A floating button, draggable, that opens the dashboard on tap (a drag never opens it) | Always reachable, never in the way |
Its position is remembered in devtools' own key-value namespace (sinew.devtools.*) | The app's preferences stay untouched |
| The dashboard has its own theme and its own back stack, shown above the app | It works the same in every app, whatever router or theme the app uses, and never pushes a route into the app's navigation |
| The button hides while the dashboard is open | |
SinewDevTools takes a preferences key-value store: devtools' own, such as one named sinew.devtools | The button's position and the chosen API host are remembered there, never in the app's store; without one, nothing is remembered |
| System back walks the dashboard's own stack, and on its first screen closes the dashboard | Back never leaves the app from inside devtools |
An uncaught error can pop up a card over the app (showUncaughtErrors); it's always recorded either way | A tester sees a crash that the app swallowed |
| The dashboard's theme follows the system's light or dark setting | Tests and goldens pin it, so images don't depend on the machine |
The launcher: where the entry point goes
The way in to the dashboard is a choice the app makes with one parameter, launcher. The dashboard, its theme and its back stack are the same whichever launcher is chosen.
| Launcher | What the developer gets | When to use it |
|---|---|---|
FloatingLauncher(initialPosition = bottomEnd) (default) | The floating button above, draggable, with its position remembered | Most apps: nothing to place, reachable on every screen |
MenuLauncher | No floating button. The app puts DevToolsMenuItem (a ready row with the devtools icon and label) wherever it wants: a settings screen, a drawer, an About page. The row opens the dashboard on tap. | Apps where a button over the screen gets in the way, or QA works from a settings menu |
CustomLauncher | No UI from devtools. The app calls DevTools.open() from any trigger it likes (a long press on the logo, a shake, a hidden tap sequence) and DevTools.close() | Apps with their own entry gesture |
| Rule | Why |
|---|---|
| The launcher only decides how the dashboard opens. Recorders, fault rules and the ribbon work the same with any launcher. | Capture never depends on the UI choice |
DevToolsMenuItem and DevTools.open() obey the same gating as the overlay: they exist only where devtools is on, and the no-op build turns them into empty stubs | A menu item can't leak devtools code into a production build |
MenuLauncher and CustomLauncher keep the dashboard's own theme and back stack | The row sits in the app's screen, but what it opens never uses the app's navigation |
The app's shared code receives only a plain callback (onOpenDevTools: (() -> Unit)?), never a devtools type | The platform entry point stays the only place that depends on devtools |
Gating
| Build | Devtools |
|---|---|
| debug, any flavor | on |
| release, non-production flavor (the builds QA installs) | on |
| release or profile, production flavor | compiled out |
| Platform | How it's compiled out |
|---|---|
| Flutter | DevToolsGate.enabled is a const, computed from the build mode and the flavor (a compile-time define). Every devtools entry point sits behind it, so release builds tree-shake the code away. A profile build of production is excluded, because a profile build is release-signed and installable. |
| Android | variant dependencies: the real artifact for debug and non-production variants, sinew-devtools-noop for production release |
| iOS / KMP | a Gradle flag picks the real or the no-op module when the framework is built |
Staging builds still mask secrets and never copy them: QA devices get shared, and screens get recorded.
Later
Inspectors that need native code ship as separate optional packages: EXIF, a camera/gallery playground, a map picker playground. Flutter links a plugin's native code into release builds even when Dart never calls it, so these must never be pulled in by sinew_devtools_ui.
Also Later:
- router adapters (route stack and parameters);
- a notification playground, after
sinew_notification; - a Camouflage skin and theme inspector, in the Camouflage family;
- an external companion that reads
sinew_devtoolsover a connection.
3. API
| Name | Signature (pseudocode) | Package |
|---|---|---|
DevToolSection, DevToolEntry, BuildRibbon | as above | devtools |
SinewDevTools | SinewDevTools(enabled, sections, ribbon, launcher = FloatingLauncher(), redaction = Redaction.default, stores: List<InspectableStore> = [], changelog: String? = null, hosts: List<String> = [], showUncaughtErrors = !debug) { app } | devtools-ui |
DevToolsLauncher | FloatingLauncher(initialPosition) | MenuLauncher | CustomLauncher | devtools-ui |
DevToolsMenuItem | a ready menu row that opens the dashboard (MenuLauncher) | devtools-ui |
DevTools.open / DevTools.close | open(), close(), isOpen | devtools (no-op without devtools) |
SinewDevTools.clearUserData | clearUserData() | devtools (no-op without devtools) |
DevToolsGate | DevToolsGate.enabled: Boolean (compile-time) | devtools |
Redaction | Redaction(headers, fieldParts, exactFields, mask, maxBodyBytes), Redaction.default, + { … } | devtools |
NetworkRecorder | NetworkRecorder(capacity = 200, redaction), .records, .clear(), .recordCacheServe(key, source, body) | devtools |
NetworkRecord | .replayable, .isReplay, .asText(), .asCurl() | devtools |
DevTools.replay | replay(record): sends the request again through the client that sent it, and records the result as a new record | devtools (no-op without devtools) |
ExceptionRecorder | ExceptionRecorder(capacity = 50, dedupeWindow = 2 s), .records, .clear() | devtools |
DevToolsCrashReporter | DevToolsCrashReporter(wrapping: CrashReporter) | devtools |
FaultRule, FaultRules | FaultRules.add(rule), .remove(rule), .clear(), .active | devtools |
HostOverride | HostOverride(hosts), .current, .select(host) | devtools |
expireAccessToken | SinewHttp.debugExpireToken(client) | network (a devtools hook, absent from release builds) |
4. Build steps
Redaction, test first. Tests:- headers;
- top-level fields;
- fields nested in objects and arrays;
- normalized keys:
refreshToken,refresh_token,Refresh-Token,newPassword,idToken,X-Api-Keyare all redacted; - every
defaultHeadersname is redacted; - a staging build's Secure Store page shows only masked values (Review Focus 5);
- query parameters;
- form bodies;
- a body over the size cap;
- a binary body;
- extending the defaults keeps
Authorization.
NetworkRecorder, with tests:- the capacity drops the oldest record;
- nothing unredacted is ever stored (assert on the stored record, not the screen);
clearUserData()empties it;replayableis false when the URL, the request's own headers or its body lost a value, or the body was cut or binary, and true when onlyAuthorizationordefaultHeaderswere masked;asText()andasCurl()contain only redacted values.
ExceptionRecorderandDevToolsCrashReporter. Tests:- de-duplication within the window;
- capacity;
- the wrapped reporter still receives every report;
- the uncaught-error hooks chain to the previous handlers.
FaultRulesin the network stack, tested: a forced 401 triggers exactly one refresh, a forced 503 on the refresh keeps the session, and a restart clears the rules.HostOverride,debugExpireTokenandDevTools.replay, tested against the mock HTTP setup. Replay: the request goes out through the same client with a fresh token (never one from the record), fault rules and the host override apply, and the result is a new record marked as a replay.sinew_devtools_ui, with the overlay and every built-in page, plus golden tests of the pages. The Network Monitor's Replay runs aGETon tap and asks first for any other method, and is disabled with its reason on a record that can't be replayed.- Gating. A CI job builds the production release (and, on Flutter, profile) variant and checks that no devtools class or symbol is in the output. On Kotlin, an ABI check confirms
sinew-devtools-noopmatches the real API.
Done when
- A production release or profile build contains no devtools code (checked in CI on every platform).
- No test can find a token, password or one-time code in any stored record.
- A forced 401 and a forced 503 on refresh each behave as the Network note says.
- An app adds its own section and its entries appear after the Sinew section.
5. Edge cases
| Case | Decided behavior |
|---|---|
| A password inside a JSON array of objects | Redacted: matching walks every depth. |
| A 20 MB response | Stored cut at 64 KB, with "20 MB" shown. |
| An image upload | Recorded as type and size only. |
| The user signs out while the Network Monitor is open | The records are cleared, and the open page shows an empty list. |
| A screen recording on a staging device shows the Secure Store page | Values are masked to their last 4 characters, so nothing usable is recorded. |
| A tester forgets an active fault rule | It's gone after the next restart, and the ribbon says "faults on" until then. |
| The app has no router, or a custom one | The dashboard uses its own back stack, so it works the same. |
| A production build by mistake depends on the real devtools | The CI gating job fails the build. |
| The app's own uncaught-error handler is already set | Devtools chains to it. The app's handler still runs. |
A tester replays a login, an OTP check or a ?token= call | Not offered: a secret in it was hidden, so the page says why instead. |
A tester replays POST /orders | Asked first, since it may place the order again. |
| A replay while the session has expired | It goes through the auth layer like any request, so the refresh runs and the replay is sent with the new token. |
| The record came from a client the app has since closed | Not replayable: the client that would add the token is gone. |
A body says it's JSON, or starts with { or [, but doesn't parse | Masked whole: it can't be walked, so nothing in it can be kept. |
| A body without a content type | Kept as text only if it's valid UTF-8 without a NUL; otherwise type and size only. Multipart bodies are always type and size only, since they mix files and fields. |
| A secret shorter than 16 characters on the Secure Store page (a PIN, a one-time code) | Only its length shows (•••• (6 chars)): its last 4 characters would give most of it away. |
A harmless name that contains a part (shippingAddress contains pin) | Masked. Matching by part errs toward hiding: a missed secret leaks, a hidden address only costs a tester a look elsewhere. An app can't narrow the parts, since the defaults are extend-only. |
Implementation
1. Why
This note builds the base devtools on Kotlin. Capture lives in commonMain, the UI on Compose Multiplatform Material 3, and release builds swap in a no-op artifact with the same API. Most of the care goes into the gating: no devtools code may reach a production build on any target.
2. Shape
Modules
| Module | Holds |
|---|---|
sinew-devtools | Redaction, NetworkRecorder, ExceptionRecorder, DevToolsCrashReporter, FaultRules, HostOverride, the entry contract, and DevTools.httpHooks, a SinewHttpHooks that feeds the recorder and applies fault rules |
sinew-devtools-ui | SinewDevTools { App() }: the overlay button, the dashboard and the pages, on Compose Material 3 with its own MaterialTheme and its own back stack (a SnapshotStateList of screens) |
sinew-devtools-noop | one module that stands in for both real modules, with the same packages and the same public API. SinewDevTools { content } just calls content(), httpHooks is SinewHttpHooks.None, and every recorder is empty. |
The no-op module has no devtools logic, but its API still names types from other modules (SinewHttpHooks from network, InspectableStore from storage, CrashReporter from exception, @Composable from the Compose runtime). So it depends on sinew-network, sinew-storage, sinew-exception and compose-runtime, exactly as the real modules expose them.
API parity: Kotlin's built-in ABI validation (abiValidation()) is on for the three modules, with reference dumps in each module's api/. checkDevtoolsNoopAbi, in CI, compares the no-op's JVM, Android and klib dumps with sinew-devtools' and sinew-devtools-ui's together, line by line. It ignores the header comments that name the library and what the Compose compiler generates (ComposableSingletons lambda holders, $stable/$stableprop), since the no-op's capture classes are built with Compose and the real sinew-devtools isn't. The no-op's stubs fail safe where a value must come back: every name is sensitive, no body is kept, nothing is recorded.
The sample's four entry points wrap the app in SinewDevTools; CI builds the Android production release (the no-op) beside staging (the real one), so the same app code compiles against both.
Wiring: only in the platform entry points
Shared code never depends on devtools. The app's commonMain takes the hooks as plain parameters (SinewHttpHooks is a network type), and only each platform entry point depends on a devtools artifact and wraps the app:
// commonMain of the app: no devtools import
fun appClients(hooks: SinewHttpHooks): Clients = Clients(main = SinewHttp.client(mainConfig, tokens, hooks = hooks))
@Composable fun App(clients: Clients) { … }
// androidApp: MainActivity (the artifact comes from the variant)
CrashReporter.install(DevToolsCrashReporter(wrapping = realReporter))
setContent { SinewDevTools(sections = listOf(productSection), ribbon = BuildRibbon(versionLabel)) { App(appClients(DevTools.httpHooks)) } }
// choosing where the entry goes (default is FloatingLauncher): a menu row the app places itself
setContent { SinewDevTools(sections = listOf(productSection), launcher = MenuLauncher) { App(appClients(DevTools.httpHooks), onOpenDevTools = DevTools::open) } }
// inside App(), in the settings screen: onOpenDevTools?.let { open -> SettingsRow("Developer tools", onClick = open) }
// or place the ready row from the platform entry point: DevToolsMenuItem()
// iosMain: MainViewController, the same lines; jvmMain / wasmJsMain: main(), the same lines
Gating: one switch per platform
| Platform | Where the switch is | Real artifact | No-op artifact |
|---|---|---|---|
| Android | the app module's variant configurations | productionDebugImplementation, and <flavor>Implementation for every non-production flavor (stagingImplementation) | productionReleaseImplementation |
| iOS | the iosMain dependencies of the module that builds the framework, chosen by the sinew.devtools Gradle property (Xcode debug and staging schemes pass true) | property true | property false or missing |
| JVM desktop, wasm | the jvmMain / wasmJsMain dependencies, by the same property | property true | property false or missing |
// the shared module that builds the iOS framework and the desktop/web apps
val devtools = providers.gradleProperty("sinew.devtools").map(String::toBoolean).orElse(false)
val devtoolsArtifact = if (devtools.get()) sinewLibs.devtools.ui else sinewLibs.devtools.noop
iosMain.dependencies { implementation(devtoolsArtifact) }
jvmMain.dependencies { implementation(devtoolsArtifact) }
wasmJsMain.dependencies { implementation(devtoolsArtifact) }
// androidMain: nothing. Android gets its artifact from the app module's variant, so it can never see both.
On non-Android targets the default is off: a build that forgets the property gets the no-op. On Android, every variant must be assigned one artifact; a new variant with none fails to compile, so the choice is always explicit.
Uncaught errors
| Target | Hook |
|---|---|
| Android, JVM | Thread.setDefaultUncaughtExceptionHandler, chained to the previous handler |
| iOS | setUnhandledExceptionHook (Kotlin/Native), chained |
| wasm | the window's error and unhandledrejection events |
| coroutines | a CoroutineExceptionHandler the app can add to its root scopes, from DevTools.coroutineHandler |
3. API
As the base note. Kotlin specifics:
| Name | Kotlin |
|---|---|
| Entry contract | in sinew-devtools-ui, since a page's content is @Composable: DevToolSection, DevToolEntry.Page/Group/Toggle/Action, BuildRibbon; DevTools.open()/close()/isOpen stay in sinew-devtools |
| Back | NavigationBackHandler (navigationevent-compose), installed only when the app provides a LocalNavigationEventDispatcherOwner: an app on an older androidx.activity gets the top bar's Back only, never a crash |
| Tests | the shared Compose UI tests run on the JVM, iOS and wasm; Android runs a Robolectric suite (androidHostTest), since a shared Compose test needs a window there. Roborazzi screenshots on the desktop and under Robolectric, with references per OS under screenshots/<os>/<platform>/: a test records what its OS lacks, and CI uploads the Linux set |
SinewDevTools | @Composable public fun SinewDevTools(sections: List<DevToolSection> = emptyList(), ribbon: BuildRibbon? = null, launcher: DevToolsLauncher = FloatingLauncher(), redaction: Redaction = Redaction.Default, stores: List<InspectableStore> = emptyList(), changelog: String? = null, hosts: List<String> = emptyList(), showUncaughtErrors: Boolean = false, preferences: KeyValueStore? = null, content: @Composable () -> Unit): common code can't tell a debug build, so the card is off unless the app turns it on |
DevTools.httpHooks | public val httpHooks: SinewHttpHooks |
DevToolsLauncher | public sealed interface DevToolsLauncher; FloatingLauncher(initialPosition: Alignment = Alignment.BottomEnd), MenuLauncher, CustomLauncher |
DevToolsMenuItem | @Composable public fun DevToolsMenuItem(modifier: Modifier = Modifier); the no-op artifact has an empty one |
DevTools.open / DevTools.close | public fun open(), public fun close(), public val isOpen: StateFlow<Boolean> |
DevTools.clearUserData | public fun clearUserData() |
Redaction | Redaction.Default + { headers += …; fieldParts += …; exactFields += …; maxBodyBytes = … }, withHeaders(names), isSensitive(name), isSensitiveHeader(name), redactHeaders(Map<String, List<String>>), redactUrl(url), redactBody(bytes, contentType): RecordedBody, Redaction.maskSecret(value). The constructor is private, so the only way to new rules is extending the defaults. |
RecordedBody | None, Text(text, size, truncated, masked), Binary(contentType, size); size is the real body size in bytes, masked whether anything was hidden |
NetworkRecorder | NetworkRecorder(capacity = 200, redaction = Redaction.Default), records: StateFlow<List<NetworkRecord>> (newest first), record(NetworkExchange): NetworkRecord, recordCacheServe(key, source, body, contentType, at), clear() |
NetworkExchange | the raw exchange the hooks hand over: method, URL, headers and bodies before redaction, status, startedAt, duration, error, clientHeaders (the client's defaultHeaders names), isReplay |
ExceptionRecorder | ExceptionRecorder(capacity = 50, dedupeWindow = 2.seconds, redaction, clock: kotlin.time.Clock), records: StateFlow<List<ExceptionRecord>>, record(error: Throwable, source = Reported), clear() |
DevTools | object DevTools { network; exceptions; faults; hosts; httpHooks; coroutineHandler; captureUncaughtErrors(); clearUserData(); canReplay(record); suspend replay(record); expireAccessToken() }; open()/close() arrive with the UI |
FaultRule, FaultRules | FaultRule(method, pathPattern, status, delay, drop, body) (validated), matches(method, path); FaultRules.active: StateFlow, add, remove, clear, match |
HostOverride | hosts, current: StateFlow<String?>, suspend configure(hosts, store: KeyValueStore?), suspend select(host?) |
DevTools.replay | public suspend fun replay(record: NetworkRecord), through the HttpClient the hooks were installed in; the no-op returns at once |
4. Build steps
Redactionwith the base test list, incommonTest.- The recorders and
DevToolsCrashReporter. DevTools.httpHookswithMockEngine: recorded exchanges are redacted, and fault rules apply insideSinewAuth.- The UI pages, with Compose UI tests and screenshot tests on Android and desktop.
sinew-devtools-noop, with its ABI dump checked equal to the real one.- The CI gating check (see Testing and CI).
Done when
- A production APK, the production iOS framework and the production desktop and web bundles contain no
com.srctool.sinew.devtoolsclasses except the no-op ones. - The real and no-op ABI dumps are identical.
5. Edge cases
| Case | Decided behavior |
|---|---|
A build without the sinew.devtools property | Off: the no-op artifact. |
An Android variant added later (preprod) | It fails to compile until the app assigns it the real or the no-op artifact. That's deliberate: no variant gets devtools, or loses them, by accident. |
| The app's own Material theme | Devtools wrap their UI in their own MaterialTheme, so the app's theme never affects them. |
- Off by default when the Gradle property is missing, so a forgotten setting fails safe.
- The real and no-op artifacts must have identical ABI dumps, which CI enforces.