Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use Chucker to Catch 'Em All

Use Chucker to Catch 'Em All

Do you know Chucker?

Chucker is an Open Source debugging tool for your Android apps that acts as an OkHttp interceptor. With Chucker, you can inspect and debug HTTP(S) requests and responses directly from your app, without the need of external desktop tools.

In this lightning talk, I will present Chucker 4.0, the latest stable release which comes packed with new feature such as GraphQL support, syntax highlighting, HAR support and much more.

It's time to stop using println to debug your network code, and start using Chucker to catch 'em all (your network requests)!

Nicola Corti

November 26, 2023
Tweet

More Decks by Nicola Corti

Other Decks in Programming

Transcript

  1. USE CHUCKER
    TO CATCH ‘EM ALL!

    View full-size slide

  2. USE CHUCKER
    TO CATCH ‘EM ALL!
    NICOLA CORTI
    cortinico

    View full-size slide

  3. NICOLA CORTI
    Kotlin GDE

    Chucker Maintainer

    twitter.com/cortinico
    github.com/cortinico
    ncorti.com
    The Developers’ Bakery Podcast
    thebakery.dev

    View full-size slide

  4. Are you ready to
    catch ‘em all?

    View full-size slide

  5. USING CHUCKER
    ChuckerTeam/chucker

    View full-size slide

  6. USING CHUCKER
    dependencies {

    }

    ChuckerTeam/chucker

    View full-size slide

  7. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    }

    ChuckerTeam/chucker

    View full-size slide

  8. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    releaseImplementation("com.github.chuckerteam.chucker:library-no-op:4.0.0")

    }

    ChuckerTeam/chucker

    View full-size slide

  9. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    releaseImplementation("com.github.chuckerteam.chucker:library-no-op:4.0.0")

    }

    ChuckerTeam/chucker

    View full-size slide

  10. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    releaseImplementation("com.github.chuckerteam.chucker:library-no-op:4.0.0")

    }

    val client: OkHttpClient = OkHttpClient.Builder().build()
    ChuckerTeam/chucker

    View full-size slide

  11. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    releaseImplementation("com.github.chuckerteam.chucker:library-no-op:4.0.0")

    }

    val client: OkHttpClient = OkHttpClient.Builder()

    .addInterceptor()

    .build()

    ChuckerTeam/chucker

    View full-size slide

  12. USING CHUCKER
    dependencies {

    debugImplementation("com.github.chuckerteam.chucker:library:4.0.0")

    releaseImplementation("com.github.chuckerteam.chucker:library-no-op:4.0.0")

    }

    val client: OkHttpClient = OkHttpClient.Builder()

    .addInterceptor(ChuckerInterceptor(context))

    .build()

    ChuckerTeam/chucker

    View full-size slide

  13. POKéDEX
    skydoves/Pokedex

    View full-size slide

  14. FEATURES
    API
    >=
    21

    OkHTTP 5 compatible

    no-op artifact

    persists network requests

    automically decode body

    export requests to file

    View full-size slide

  15. MULTI-WINDOW

    View full-size slide

  16. MULTI-WINDOW

    View full-size slide

  17. CONFIGURE CHUCKER
    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  18. CONFIGURE CHUCKER
    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context).build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  19. CONFIGURE CHUCKER
    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .maxContentLength(250_000L)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  20. CONFIGURE CHUCKER
    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  21. CONFIGURE CHUCKER
    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  22. CONFIGURE CHUCKER
    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .collector(chuckerCollector)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  23. CONFIGURE CHUCKER
    public val chuckerCollector = ChuckerCollector(

    )

    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .collector(chuckerCollector)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  24. CONFIGURE CHUCKER
    public val chuckerCollector = ChuckerCollector(

    context = this,

    )

    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .collector(chuckerCollector)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  25. CONFIGURE CHUCKER
    public val chuckerCollector = ChuckerCollector(

    context = this,

    showNotification = true,

    )

    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .collector(chuckerCollector)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  26. CONFIGURE CHUCKER
    public val chuckerCollector = ChuckerCollector(

    context = this,

    showNotification = true,

    retentionPeriod = RetentionManager.Period.ONE_HOUR

    )

    public val chuckerInterceptor =
    ChuckerInterceptor.Builder(context)

    .collector(chuckerCollector)

    .maxContentLength(250_000L)

    .redactHeaders("Auth-Token", "Bearer")

    .alwaysReadResponseBody(true)

    .build()

    public val client = OkHttpClient.Builder()

    .addInterceptor(chuckerInterceptor)

    .build()

    View full-size slide

  27. New in 4.0.0
    🎉

    View full-size slide

  28. DECODING
    interceptorBuilder.addBodyDecoder(MyCustomDecoder).build()
    gzip brotli custom

    View full-size slide

  29. DECODING
    public object MyCustomDecoder : BodyDecoder {

    }

    interceptorBuilder.addBodyDecoder(MyCustomDecoder).build()

    gzip brotli custom

    View full-size slide

  30. DECODING
    public object MyCustomDecoder : BodyDecoder {

    override fun decodeRequest(request: Request, body: ByteString): String? =

    if (shouldDecode()) {

    "¯\\_(ツ)_/¯"

    } else {

    null

    }

    }

    interceptorBuilder.addBodyDecoder(MyCustomDecoder).build()

    gzip brotli custom

    View full-size slide

  31. DECODING
    public object MyCustomDecoder : BodyDecoder {

    override fun decodeRequest(request: Request, body: ByteString): String? =

    if (shouldDecode()) {

    "¯\\_(ツ)_/¯"

    } else {

    null

    }

    override fun decodeResponse(request: Response, body: ByteString): String? =

    if (shouldDecode()) {

    "(┛◉Д◉)┛

    ┻━┻"

    } else {

    null

    }

    }

    interceptorBuilder.addBodyDecoder(MyCustomDecoder).build()

    gzip brotli custom

    View full-size slide

  32. GRAPH-QL
    operation-name Header

    /graphql in path segment

    graphql in host

    View full-size slide

  33. NOTIFICATIONS

    View full-size slide


  34. Looking for maintainers 🙏

    View full-size slide

  35. SEE YOU ON FRI?
    FRIDAY - 1.25 PM - LOVELACE

    View full-size slide

  36. THANK YOU
    NICOLA CORTI
    cortinico
    ChuckerTeam/chucker

    View full-size slide