Giter Site home page Giter Site logo

sankarvaiyapuri / androidsnooper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jainsahab/androidsnooper

0.0 1.0 0.0 9.05 MB

Android library to record the network calls through the interceptor mechanism of the http clients.

License: Apache License 2.0

Shell 0.37% Kotlin 99.19% Java 0.45%

androidsnooper's Introduction

Android Snooper

Build Status codecov Maven Central BCH compliance HitCount

Introduction

Android Snooper is a library which helps in debugging issues while running the applications on android devices. One of the basic features provided includes HTTP inspection, which observes all the HTTP calls made by the app. When the device is shaked, history of all the HTTP requests is presented with their responses and allows search, copy and sharing of the request/response. This library is inspired by the Network Request History feature of FLEX app for iOS.

Snooper

How to use?

Android Snooper works on the interceptor pattern which is supported by almost every HTTP client. All you need to do is initialize Android Snooper using AndroidSnooper.init(this); statement in your Application class and set an instance of SnooperInterceptor to the list of your network interceptors. As of now Snooper supports the interceptors for the following libraries:

Didn't get your HTTP client's name in the list? No worries, You can still write your own implementation by using Android Snooper's core module and let Android Snooper know about the request being made. Below is given a dummy implementation.

    AndroidSnooper androidSnooper = AndroidSnooper.getInstance();
    HttpCall httpCall = new HttpCall.Builder()
      .withUrl(httpRequest.getUrl())
      .withPayload(httpRequest.getRequestPayload())
      .withMethod(httpRequest.getMethod())
      .withResponseBody(httpResponse.getResponseBody())
      .withStatusCode(httpResponse.getRawStatusCode())
      .withStatusText(httpResponse.getStatusCode())
      .withRequestHeaders(httpRequest.getHeaders())
      .withResponseHeaders(httpResponse.getHeaders())
      .build();
    androidSnooper.record(httpCall);

The above implementation ought to be part of your custom interceptor where you will have access to the required Request and Response object to jot down the required data for Android Snooper to work properly.

Warning: Android Snooper records each and every HTTP call intercepted by it. The sole purpose of Android snooper is to help in debugging, hence only Debug or QA builds are the perfect candidates for integrating the library. Sensitive information such as Auth Tokens, Headers, etc are not supposed to be exposed and hence production apps should not integrate the library.

Integration

    repositories {
        mavenCentral()
    }

    // when using Android Snooper's core module
    compile ('com.github.jainsahab:Snooper:1.5.5@aar'){
      transitive = true
    }

    // Android Snooper library for "Spring Android Rest Template"
    compile ('com.github.jainsahab:Snooper-Spring:1.5.5@aar'){
      transitive = true
    }
    
    // Android Snooper library for "Square's Okhttp"
    compile ('com.github.jainsahab:Snooper-Okhttp:1.5.5@aar'){
      transitive = true
    }

Snapshot versions are available in Sonatype's snapshots repository.

Contributing

If you would like to contribute code to AndroidSnooper you can do so by forking the repository and create a Pull request. You can also create an Issue to report bugs or features that you want to see in AndroidSnooper library.

Attributions

This library uses:

LICENSE

Copyright (C) 2017 Prateek Jain

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

androidsnooper's People

Contributors

harshnaraini avatar its-snorlax avatar jainsahab avatar nullptr2this avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.