top of page
  • Writer's pictureDon Peter

Monitoring HTTP requests in Android apps

Updated: Sep 25, 2022

Have you ever thought about the importance of a medium in the communication process? A medium, as we know, is a channel through which information is circulated between the sender and the receiver. What if the medium encounters a problem? It then becomes a barrier to an effective communication process.


Similarly, an HTTP API call acts as a medium of communication between the mobile app and the server. Failures in HTTP calls are critical as it affects the functioning of the app, which may lead to users uninstalling the app.


What could be the reasons for HTTP request failure?


Consider a scenario where your app user types all the required credentials in the login screen of your Android app and taps on the login button but nothing happens. As the page becomes unresponsive, chances are your users may uninstall your app never to return. We consider HTTP call issues as fatal issues right up there along with app crashes.


How to overcome this situation?


HTTP request failures can occur when the app sends incorrect data to the server, delayed calls, exceptions thrown during an HTTP call or even executing duplicate HTTP calls. The thing to note here is that developers need to be notified of such issues in real time.


Now the question in your mind will be, should I use a bug reporting tool to manually call functions to report HTTP request issues on every callback block? Well that is messy and time consuming.


Instead, an automated HTTP request tracking mechanism will serve the purpose.

By enabling the HTTP tracking mechanism in Finotes SDK with a single line of code, developers will be able to monitor for failures in all okhttp based API calls originating from the application.

Java code snippet on activating HTTP tracking with Finotes


//Current OkHttpClient code.
client = new OkHttpClient.Builder().build();

Change to,


import com.finotes.android.finotescore.OkHttp3Client;

...

//Finotes based OkHttpClient code.
client = new OkHttp3Client(new OkHttpClient.Builder()).build();



Kotlin code snippet on activating HTTP tracking with Finotes


//Current OkHttpClient code.
var client = OkHttpClient.Builder().build()

Change to,


import com.finotes.android.finotescore.OkHttp3Client

...

//Change to Finotes based OkHttpClient code.
var client = OkHttp3Client(OkHttpClient.Builder()).build()

Please find our detailed Java and Kotlin documentation on enabling HTTP tracking with libraries like OkHttp, Retrofit and Volley.


Are the developers getting notified of HTTP issues enough?


The answer is a big No.


The next logical step is to be able to reproduce and fix them fast. In order to accomplish this, we need to have access to precise data points involved in the execution of an API call.


Finotes SDK is capable of generating detailed bug reports with data points like complete URL, URL parameters, status code, request body and request-response headers.


But what about user sensitive data?


Making sure that privacy and security is maintained is of utmost importance especially when dealing with HTTP request monitoring. Most of the HTTP calls will have authorization tokens and other sensitive data in the header fields. The tool that is used to track HTTP requests should have a way to mask the sensitive data from the application side itself, which will prevent this data from reaching third party servers.


Finotes provides a simple and easy to use @Observe annotation to enable filtering such sensitive data and prevent it from being sent to the Finotes dashboard. Please find our detailed Java and Kotlin documentation.


Java code snippet on filtering sensitive header fields in request and response of an HTTP call


@Observe(maskHeaders = {"X-Key", "Accept"})
public class BlogApp extends Application {
        @Override
        public void onCreate() {
                super.onCreate();
                Fn.init(this);
        }
}

Kotlin code snippet on filtering sensitive header fields in request and response of an HTTP call


@Observe(maskHeaders = {"X-Key", "Accept"})
class BlogApp: Application() {
        override fun onCreate() {
                super.onCreate()
                Fn.init(this)
        }
}
        

Apart from these, data points like device and device state data along with activity trail will also be included with every issue report.

Finotes is capable of detecting HTTP request issues in iOS and watchOS apps. Apart from this, SDK is capable of detecting and reporting crashes, frame rate issues, ANR, function failures, feature failures, memory leaks, abnormal memory usage, exceptions and custom issues.

Finotes is available for Android as Java & Kotlin SDK, iOS as Objective- C & Swift Framework and watchOS as Objective-C & Swift Framework.


Visit finotes.com to learn more about Finotes. Detailed documentation is available at docs.finotes.com.

Blog for Mobile App Developers, Testers and App Owners

 

This blog is from Finotes Team. Finotes is a lightweight mobile APM and bug detection tool for iOS and Android apps.

In this blog we talk about iOS and Android app development technologies, languages and frameworks like Java, Kotlin, Swift, Objective-C, Dart and Flutter that are used to build mobile apps. Read articles from Finotes team about good programming and software engineering practices, testing and QA practices, performance issues and bugs, concepts and techniques. 

bottom of page