Inspektify: KMP network inspection library

Blaž Vantur
Kt. Academy
Published in
4 min readSep 23, 2024

Network communication in mobile applications nowadays is something normal for almost every app. Much of the information presented in our apps is fetched from the network and then shown to the users in a compelling way. And while we are developing and testing our apps, we usually need some tooling to see what is being fetched from the network and how that is being done. But what if we could change that and enable every team member possibility to see such information at every step of our mobile development process?

MEET INSPEKTIFY

Inspektify is a debug tool for observing the app's real-time network traffic. It enables all team members to access all network details directly on the device where an application is being run. No additional tooling is needed, no development setups on your computers, no need to connect your phone to your computer, no technical knowledge (besides for developers to include lib to the project), or other complex additional steps are needed for this. We can have access to all network information directly on our phones. With minimum library setup all we need to do is to shake our mobile device and a new window is presented with a list of all network communication that happened within the app.

TECHNICAL SETUP FOR TECHNICAL PEOPLE

To use the Inspektify library, currently, we need to fulfill 3 requirements:

  1. It can only be used for KMP projects that support only Android and iOS platforms.
  2. The library heavily depends on Ktor, so we need to use the Ktor library for network communication in our project to set up Inspektify.
  3. A project consuming this library must have a minimum Ktor version of 2.3.1.

If we made a check for all three requirements then we can use Inspektify in our project and we need to do the next steps to include it:

  1. Add the mavenCentral() repository to our project if we don’t have it yet.

2. Include the library in our commonMain source set.

If you are using Ktor version that is below 3.0.0, please use inspektify-ktor2 instead of inspektify-ktor3

3. Install the Inspektify plugin on our Ktor client.

This is a minimum needed setup to include a library in the project. If we want we can also configure the library further with instructions written on the project’s GitHub page here.

USAGE

With a minimum setup, we can already use our library directly on our Android and iOS clients. All we need to do is shake our phone and the Inspektify tool window will be presented to us automatically. At first, we will see a list of all network transactions(which are stored in a database), ordered by the date and time. All transactions are grouped by the date with sticky headers We can also easily see which transactions are from the current session and which are from the past sessions. This is visible with the background color of items. If they are a little bit grayed out they are from the past sessions. In the top right corner is a trash icon with which we can remove all the items from the list(and also from the database). For every transaction we can see the next data:

  1. Endpoint name
  2. Response status code
  3. SSL information(only on Android)
  4. Host name
  5. A time when a network transaction happened
  6. Duration of network transaction
  7. Total sized transferred between app and server

We can see more details about the transaction when we click on a single item. Data there is presented with 3 tabs. In the Overview tab, we can see all the general information about the transaction. Then we have the Request and the Response tabs where we see all the headers and payloads sent and received with our app. On the top right corner here we have a copy icon, which copies the whole network transaction to the device’s clipboard, which can be later on used for whatever case we want(sending it through email, slack, discord,….)

DISCLAIMER

This is an early library version, so it still needs to be tested with bigger and more complex projects. I hope you will give it a go. There is also a sample project on the GitHub repo, so you can do a quick check there if that is something that could help your development process within your team. If you find any issues, please file them directly on the project GitHub page so they can be investigated.

CONCLUSION

The library is still in beta and I am trying to gather some feedback before it goes to the stable version. I am happy to hear any recommendations or ideas, so don’t hesitate to contact me.

Learn @ Kt.Academy

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Written by Blaž Vantur

Experienced Mobile Developer with an 12-year long history of working in the computer software industry. Skilled in Kotlin, Java, Android, Swift, and iOS.

No responses yet

What are your thoughts?