Skip to content

skymansandy/wiretapKMP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WiretapKMP — Powerful, Cross-Platform Network Inspection for Kotlin Multiplatform

Build Coverage Maven Central

WiretapKMP is a drop-in network inspector and mocker for Kotlin Multiplatform apps. Add one dependency, install the plugin, and inspect every HTTP request, WebSocket message, and SSE event — or mock and throttle them — all from a built-in UI. No proxy needed.

Early Preview — We're looking for early adopters and feedback! Open an issue or start a discussion.

🚀 Quick Start

// Ktor
val client = HttpClient {
    install(WiretapKtorHttpPlugin)
}

// OkHttp
val client = OkHttpClient.Builder()
    .addInterceptor(WiretapOkHttpInterceptor())
    .build()

That's it. Open your app and shake the device (or press Ctrl+Shift+D on desktop) to launch the inspector.

✅ What You Get

HTTP WebSocket SSE
Ktor
OkHttp
URLSession
Android iOS JVM Desktop
Ktor
OkHttp
URLSession

📸 Screenshots

Overview Request Response
WebSocket Messages Notifications

⭐ Key Features

  • Zero-config logging — install the plugin and all traffic is captured automatically
  • API mocking — return fake responses without hitting the network. Match on method, URL, headers, and body
  • Request throttling — simulate slow connections with fixed or random delays
  • Header masking — redact Authorization, Cookie, or any sensitive header from logs
  • Shake to launch — built-in gesture to open the inspector (no UI code required)
  • No-op variants — swap to wiretap-ktor-noop / wiretap-okhttp-noop for release builds with zero overhead
  • Share as file — export any log entry via the platform share sheet
More screenshots

API Mocking & Rules Engine

Mocked Requests Mock Rule Rules List

List-Detail Pane (Tablet / Desktop)

📡 SSE Inspection (Experimental)

WiretapKMP can inspect Server-Sent Events (SSE) streams — log every connection, event, and status change right alongside your HTTP and WebSocket traffic.

⚠️ SSE inspection is in early preview. APIs are marked with @ExperimentalWiretapSseApi and may change in future releases.

Ktor

Install the SSE plugin and wrap your session:

@OptIn(ExperimentalWiretapSseApi::class)
val client = HttpClient {
    install(SSE)
    install(WiretapKtorSsePlugin)    // SSE logging
    install(WiretapKtorHttpPlugin)   // HTTP logging
}

client.sse("https://api.example.com/stream") {
    val session = this.wiretapped()
    session.incoming.collect { event ->
        println("Event: ${event.event}${event.data}")
    }
}

OkHttp

Wrap your EventSourceListener with .wiretapped():

val client = OkHttpClient.Builder()
    .addInterceptor(WiretapOkHttpInterceptor())
    .build()

val request = Request.Builder().url("https://api.example.com/stream").build()
val factory = EventSources.createFactory(client)

@OptIn(ExperimentalWiretapSseApi::class)
factory.newEventSource(request, myListener.wiretapped())

What Gets Logged

Connection Events
URL, headers, status (Open → Closed/Failed), timestamps Event type, data payload, event ID, byte count, timestamp

For full details, see the Ktor SSE guide and OkHttp SSE guide.

📦 Installation

// build.gradle.kts
debugImplementation("dev.skymansandy:wiretap-ktor:1.0.0-RC10")
releaseImplementation("dev.skymansandy:wiretap-ktor-noop:1.0.0-RC10")

// or for OkHttp
debugImplementation("dev.skymansandy:wiretap-okhttp:1.0.0-RC10")
releaseImplementation("dev.skymansandy:wiretap-okhttp-noop:1.0.0-RC10")

For full setup including URLSession and advanced configuration, see the Getting Started guide.

📖 Documentation

Full docs · Getting Started · API Reference

🤝 Contributing

Contributions are welcome! Fork the repo, create a feature branch, and open a PR.

🙏 Acknowledgements

Kotlin Multiplatform · Compose Multiplatform · Ktor · Room · Koin · OkHttp · SKIE · KMMBridge