Skip to main content
Version: 6.0.0

Track Network Calls

Finotes will be able to notify issues in API calls with just a single line of code.

Retrofit- no existing okhttpclient

Add Finotes client using .client() function:


OkHttpClient client = new OkHttp3Client(new OkHttpClient.Builder()).build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();

Retrofit- already using okhttpclient

Pass the current builder to OkHttp3Client and .build():


OkHttpClient.Builder currentBuilder = new OkHttpClient.Builder();
... //Builder customization codes
...
OkHttpClient client = new OkHttp3Client(currentBuilder).build();

Incase, you need more clarity on integrating Retrofit with OkHttp3Client, Please initiate a chat with our development team directly using chat widget at the bottom right corner. We will help you overcome any roadblocks that you may have.

OkHttp

If OkHttp is directly used to make API calls, find the code block where the OkHttpClient is initialized.
In case more than one OKHTTP client is initialized, change the default client to custom OkHttp3Client provided by Finotes.


client = new OkHttp3Client(new OkHttpClient.Builder()).build();

Volley 1.1.0

As volley does not directly support OkHttpClient we need to use HurlStack.

  1. You need to add HurlStack class from HurlStack Gist to your project.
  1. Find the below function where newRequestQueue is initiated either in a singleton (used as ApiManger for volley) class or Application class.

mRequestQueue = Volley.newRequestQueue(getApplicationContext());

  1. Replace the above code with the following snippet.

public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext(),
new HurlStack());
}
return mRequestQueue;
}

4. Add implementation 'com.squareup.okhttp3:okhttp:3.8.0' to your build.gradle.

Incase, you need more clarity on integrating Volley with HurlStack, Please initiate a chat with our development team directly using chat widget at the bottom right corner. We will help you overcome any roadblocks that you may have.

Dynamic Path Component

When API call issues are reported, issues from different urls are created as separate ticket.
This can cause large number of tickets generated for the same API incase the url contains an id or any other dynamic path components.

Application Class:


@Observe(urlPatterns = {"https://your-host.com/path_element/{id}/{another_id}/path_element",
"https://your-host.com/path_element/{id}"})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}

Use urlPatterns with @Observe annotation to specify the urls that contains dynamic path component. Wrap the corresponding "dynamic path component" or "id" inside curly braces.

Privacy

As Finotes reports API call issues, each issue is tagged with corresponding request response headers, request body and associated parameters.

If header fields contain any sensitive data, Finotes provides a global and easy mechanism to mask such header fields using maskHeaders in @Observe annotation as shown in code snippet.
You may provide 1 or more header keys in the 'maskHeaders' field.

Application Class:


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

Whitelisting domains

Using the domains key in @Observe annotation, domains can be whitelisted. Once set only HTTP(s) calls made to the whitelisted domains will be tracked by the SDK.

Application Class:


@Observe( domains = {@Domain( hostName = "your-domain.com")
, @Domain( hostName = "another-domain.com")} )

public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}

Setting Domain timeout

Setting domain timeout is an extension of whitelisting domains. Developers can set timeout to whitelisted domains using the timeout key along with hostName key.

The timeout value should be in milliseconds. Once the value is set if any of the HTTP(s) calls to the domain takes more than the set amount of time, an issue report will be raised.

Application Class:


@Observe( domains = {@Domain( hostName = "your-domain.com", timeOut = 5000)
, @Domain( hostName = "another-domain.com", timeOut = 10000)} )

public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}