Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

245 Commits

Repository files navigation

DevView

DevViewDevView

A Kotlin Multiplatform library that adds an in-app developer overlay to Android and iOS apps. The overlay hosts pluggable modules for feature flags, analytics inspection, and network mocking.

Full documentation:worldline.github.io/devview


Requirements

  • Android minSdk 26
  • iOS 16+
  • Kotlin 2.x
  • Compose Multiplatform

Installation

DevView is published to Maven Central. Add the modules you need to your shared KMP module:

// build.gradle.kts (shared / commonMain)
dependencies {
implementation("com.worldline.devview:devview:<version>") // core — always required
implementation("com.worldline.devview:devview-featureflip:<version>") // feature flags
implementation("com.worldline.devview:devview-analytics:<version>") // analytics inspector
implementation("com.worldline.devview:devview-timecapsule:<version>") // per-screen state history
implementation("com.worldline.devview:devview-networkmock:<version>") // network mock UI// Ktor plugin only (no UI — lightweight alternative for network-layer integration)
implementation("com.worldline.devview:devview-networkmock-core:<version>")
implementation("com.worldline.devview:devview-networkmock-ktor:<version>")
}

Quick Setup

1. Register modules and render the overlay

@Composable
funMyApp() {
val modules = rememberModules {
module(module =FeatureFlip)
module(module =Analytics())
module(
module =NetworkMock(
resourceLoader = { path ->Res.readBytes(path = path) }
)
)
}
var devViewOpen by remember { mutableStateOf(false) }
// Your existing app contentAppContent(onOpenDevView = { devViewOpen =true })
// DevView overlayDevView(
devViewIsOpen = devViewOpen,
closeDevView = { devViewOpen =false },
modules = modules
)
}

rememberModules handles DataStore initialisation and module setup automatically. DevView renders as a transparent overlay on top of your content.

2. Feature Flags

Define flags and provide the handler to the composition:

val featureHandler = rememberFeatureHandler(
features =listOf(
Feature.LocalFeature(name ="dark_mode", description ="Enable dark theme", isEnabled =false),
Feature.RemoteFeature(
name ="new_checkout",
description ="New checkout experience",
defaultRemoteValue = remoteConfig.getBoolean("new_checkout"),
state =FeatureState.REMOTE
)
)
)
CompositionLocalProvider(LocalFeatureHandler provides featureHandler) {
// Read flags anywhere in the treeval isDarkMode by LocalFeatureHandler.current.isFeatureEnabled("dark_mode")
}

3. Analytics

Forward events to AnalyticsLogger from your existing analytics layer:

AnalyticsLogger.log(
AnalyticsLog(
tag ="purchase_completed",
screenClass ="CheckoutScreen",
timestamp =Clock.System.now().toEpochMilliseconds(),
type =AnalyticsLogCategory.Ecommerce.Purchase
)
)

Provide the log list above DevView:

CompositionLocalProvider(LocalAnalytics provides AnalyticsLogger.logs) { … }

4. Network Mocking (Ktor)

Place your mock config at composeResources/files/networkmocks/mocks.json and install the plugin:

val client =HttpClient(OkHttp) {
install(NetworkMockPlugin)
}

rememberModules { } must be called (and composed) before the first HTTP request reaches this client.

5. TimeCapsule

Implement TimeCapsuleOwner on a screen's state holder and record it with one call:

classCounterViewModel : ViewModel(), TimeCapsuleOwner<CounterState> {
overrideval state:StateFlow<CounterState> =_state.asStateFlow()
overridefunrestoreState(state:CounterState) { _state.value = state }
}
@Composable
funCounterScreen(viewModel:CounterViewModel) {
TimeCapsuleEffect(owner = viewModel)
}

The recorded history resets automatically when the screen leaves composition.


Available Modules

ModuleArtifactDescription
CoredevviewDevView composable + rememberModules DSL. Required by all modules.
FeatureFlipdevview-featureflipRuntime feature flag management with Compose UI. Supports local and remote-config flags with local overrides.
Analyticsdevview-analyticsReal-time analytics event inspector with filtering by type, category, and time range.
TimeCapsuledevview-timecapsuleRecords the state history of the currently visible screen and lets you restore any earlier state back into it.
NetworkMock (UI)devview-networkmockFull mock management UI: enable/disable endpoints, switch responses, preview and diff mock payloads.
NetworkMock Coredevview-networkmock-coreMock engine: JSON config parsing, request matching, DataStore state. No UI dependency.
NetworkMock Ktordevview-networkmock-ktorKtor HttpClientPlugin that intercepts requests and returns mock responses.

Acknowledgments

DevView's build infrastructure, CI setup, and library conventions draw inspiration from chrisbanes/haze. Many thanks to Chris Banes for open-sourcing that work.


License

Apache License 2.0

About

A powerful, modular developer tools framework for Kotlin Multiplatform applications

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages