Sherlock (In-App Network Proxy)

Additional

Language
Kotlin
Version
1.1.7 (Mar 3, 2019)
Created
Sep 9, 2018
Updated
May 10, 2022 (Retired)
Owner
Mohamed Osman (shehabic)
Contributor
Mohamed Osman (shehabic)
1
Activity
Badge
Generate
Download
Source code

Sherlock

Sherlock is a shorthand for "Network Sherlock Holmes" a simple lib that you can plug into your http client to capture everything around network requests, which then provides you or your QA team member with enough info about requests.

Why not use a proxy?

  • Sherlock is not to replace your normal proxy like. Charles Proxy for example, however the right question would be .. how many times did something go wrong while QAing your app then you realized that it's too late as you were not proxying?

How to use it?

it's a very simple and straight forward for v.0.X only OKHttp is supported.

  1. Add the dependency to your gradle.
allprojects {
    repositories {
 maven { url 'https://jitpack.io' }
    }
}
dependencies {
    debugImplementation 'com.github.shehabic.sherlock:sherlock:v0.11.0'
    releaseImplementation 'com.github.shehabic.sherlock:sherlock-no-op:v0.11.0'
    
    // the next part is important (until there is a better solution)
    implementation "android.arch.persistence.room:runtime:$architecture_version"
    // if your project uses kotlin:
    kapt "android.arch.persistence.room:compiler:$architecture_version"
    // or if your project doesn't use kotlin:
    annotationProcessor "android.arch.persistence.room:compiler:$architecture_version"
}
  1. on app startup initialize sherlock by NetworkSherlock.getInstance().init(appContext)
  2. then attach Sherlock's okhttp intercepter to your OKHttpClient as follows:

Kotlin

val client: OkHttpClient = OkHttpClient.Builder().addInterceptor(SherlockOkHttpInterceptor()).build()

Java

OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new SherlockOkHttpInterceptor()).build()

Advanced options

Show/Hide anchor - Show/Hide network activity indicator Kotlin

NetworkSherlock
  .getInstance(NetworkSherlock.Config(showAnchor = true, showNetworkActivity = true))
  .init(this)

Pause/Resume Recording

NetworkSherlock.getInstance().pauseRecording()
NetworkSherlock.getInstance().resumeRecording()

Check the demo app which is using many feature of Sherlock's lib

Roadmap

Enahnce Export Format

  • Export whole sessions in a machine readable format
  • Export request in cURL format
  • Export standard http-request format
  • Export Charles-Proxy files for sessions