Android Network Monitoring Customization - Whitelisting, Privacy, and Timeout with Appxiom SDK
By default, Appxiom SDK monitors all HTTP(s) calls for issues in your Android application. You can customize which hosts and endpoints are monitored, group dynamic API paths, mask sensitive headers, and set timeouts for specific endpoints to enhance privacy and reduce noise in your dashboard.
Whitelisting Hosts for Network Monitoring
By default all API calls made by your app are monitored. However, you may want to limit monitoring to specific hosts to reduce noise or focus on critical endpoints.
Use the MonitoredHost parameter in the @AX annotation to whitelist specific hosts. Only HTTP(s) calls made to these hosts will be tracked by the SDK.
Example: Whitelisting Hosts
- Java
- Kotlin
@AX(HTTPMonitoring = {@MonitoredHost(host = "your-host.com"), @MonitoredHost(host = "another-host.com")})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Ax.init(this, appKey, platformKey);
}
}
@AX(HTTPMonitoring = [MonitoredHost(host = "your-host.com"), MonitoredHost(host = "another-host.com")])
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Ax.init(this, appKey, platformKey)
}
}
Grouping Dynamic Path Components
When API call issues are reported, issues from different URLs are created as separate tickets. If the URL contains an ID or other dynamic path components, this can generate many tickets for the same API. Use pathPatterns with @MonitoredHost to group such calls.
If you want to set path patterns for all API calls use * in host field as shown in example. This will set path patterns for all API calls made by your app.
Example: Grouping Dynamic Paths
- Java
- Kotlin
@AX(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "/{id}/{another_id}/path_element"),
@PathPattern(path = "/path_element/{id}")})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Ax.init(this, appKey, platformKey);
}
}
@AX(HTTPMonitoring = [MonitoredHost(host = "*",
pathPatterns = [PathPattern(path = "/{id}/{another_id}/path_element"),
PathPattern(path = "/path_element/{id}")])])
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Ax.init(this, appKey, platformKey)
}
}
Use curly braces {} to wrap dynamic path components. Calls matching each pattern will be grouped into a single ticket for each PathPattern.
Privacy: Masking Sensitive Headers
By default all available header fields and their values are reported in network issues. However, some headers may contain sensitive information that should not be exposed.
Appxiom SDK allows you to mask sensitive header fields in network reports using the maskedHeaders field in the @AX annotation. Specify one or more header keys to be masked before reporting.
Once set, the header field names will be reported in the issue report, but their values will be masked with * to protect sensitive information.
If you want to mask headers for all API calls use * in host field as shown in example. This will mask specified header values from all API calls made by your app.
Example: Masking Headers
- Java
- Kotlin
@AX(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", maskedHeaders = {"X-Key"}),
@PathPattern(path = "/users", maskedHeaders = {"X-Key", "Accept"})})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Ax.init(this, appKey, platformKey);
}
}
@AX(HTTPMonitoring = [MonitoredHost(host = "*",
pathPatterns = [PathPattern(path = "*", maskedHeaders = ["X-Key"]),
PathPattern(path = "/users", maskedHeaders = ["X-Key", "Accept"])] )])
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Ax.init(this, appKey, platformKey)
}
}
Setting Host or Endpoint Timeout
Set a timeout for endpoints using the networkTimeout key in the PathPattern annotation. The timeout value is in milliseconds. Calls exceeding this time will be reported as issues.
If you want to set network timeout for all API calls use * in host field as shown in example. This will set network timeout for all API calls made by your app.
Example: Setting Timeout
- Java
- Kotlin
@AX(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", networkTimeout = 4000),
@PathPattern(path = "/fileUpload", networkTimeout = 50000)})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Ax.init(this, appKey, platformKey);
}
}
@AX(HTTPMonitoring = [MonitoredHost(host = "*",
pathPatterns = [PathPattern(path = "*", networkTimeout = 4000),
PathPattern(path = "/fileUpload", networkTimeout = 50000)] )])
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Ax.init(this, appKey, platformKey)
}
}
Best Practices for Network Monitoring
- Whitelist only necessary hosts to reduce noise and focus on critical endpoints.
- Group dynamic API paths to avoid duplicate tickets for similar endpoints.
- Mask sensitive headers to protect user privacy and comply with data protection policies.
- Monitor the Appxiom dashboard for all reported network issues.
Frequently Asked Questions (FAQ)
Q: What network calls does Appxiom SDK monitor by default?
A: By default, Appxiom SDK monitors all HTTP(s) calls triggered from your app.
Q: How do I whitelist specific hosts for monitoring?
A: Use the MonitoredHost parameter in the @AX annotation to specify which hosts should be tracked. Only calls to these hosts will be monitored.
Q: How do I allow monitoring for all hosts?
A: By default all hosts are monitored.
Q: What is the purpose of pathPatterns in network monitoring?
A: pathPatterns allows you to group API calls with dynamic path components (like IDs) so that similar calls are reported as a single ticket, reducing noise in the dashboard.
Q: How can I mask sensitive headers in network reports?
A: Use the maskedHeaders field in the PathPattern annotation to specify which header fields should be masked before reporting.
Q: How do I set a timeout for specific endpoints?
A: Use the networkTimeout key in the PathPattern annotation to set a timeout (in milliseconds) for specific endpoints. Calls exceeding this time will be reported as issues.