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:
- Java
- Kotlin
OkHttpClient client = new OkHttp3Client(new OkHttpClient.Builder()).build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
val client = OkHttp3Client(OkHttpClient.Builder()).build()
val retrofit = Retrofit.Builder()
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
Retrofit- already using okhttpclient
Pass the current builder to OkHttp3Client and .build():
- Java
- Kotlin
OkHttpClient.Builder currentBuilder = new OkHttpClient.Builder();
... //Builder customization codes
...
OkHttpClient client = new OkHttp3Client(currentBuilder).build();
val currentBuilder = OkHttpClient.Builder()
... //Builder customization codes
...
val client = 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.
- Java
- Kotlin
client = new OkHttp3Client(new OkHttpClient.Builder()).build();
var client = OkHttp3Client(OkHttpClient.Builder()).build()
Volley 1.1.0
As volley does not directly support OkHttpClient we need to use HurlStack.
- You need to add HurlStack class from HurlStack Gist to your project.
- Find the below function where newRequestQueue is initiated either in a singleton (used as ApiManger for volley) class or Application class.
- Java
- Kotlin
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
return Volley.newRequestQueue(applicationContext)
- Replace the above code with the following snippet.
- Java
- Kotlin
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext(),
new HurlStack());
}
return mRequestQueue;
}
val requestQueue: RequestQueue? = null
get() {
if (field == null) {
return Volley.newRequestQueue(applicationContext, HurlStack())
}
return field
}
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
This API is now deprecated and will be removed in a future version. Use Customize Network Monitoring API.
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:
- Java
- Kotlin
@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);
}
}
@Observe(urlPatterns = {"https://your-host.com/path_element/{id}/{another_id}/path_element",
"https://your-host.com/path_element/{id}"})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Privacy
This API is now deprecated and will be removed in a future version. Use Customize Network Monitoring API.
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:
- Java
- Kotlin
@Observe(maskHeaders = {"X-Key", "Accept"})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}
@Observe(maskHeaders = {"X-Key", "Accept"})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Whitelisting domains
This API is now deprecated and will be removed in a future version. Use Customize Network Monitoring API.
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:
- Java
- Kotlin
@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);
}
}
@Observe( domains = {@Domain( hostName = "your-domain.com")
, @Domain( hostName = "another-domain.com")} )
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Setting Domain timeout
This API is now deprecated and will be removed in a future version. Use Customize Network Monitoring API.
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:
- Java
- Kotlin
@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);
}
}
@Observe( domains = {@Domain( hostName = "your-domain.com", timeOut = 5000)
, @Domain( hostName = "another-domain.com", timeOut = 10000)} )
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}