API tracking for Android apps
API Tracking is a part of Apptics' Analytics SDK which allows you to track the success rate and response time for the REST APIs configured in the Apptics web console. Refer to the User Guide to configure APIs in the web console.
- Before you begin, make sure that Apptics is integrated into your project by following the Integration Guide.
Copied
- If you do not use Apptics BoM, you can directly declare the analytics dependency with its version.
Copied
Note: It is recommend to use Apptics BoM to avoid unnecessary compatibility issues.
- Initialize analytics in application onCreate() method.
Copied
Tracking APIs
You can track APIs only after configuring them in the Apptics web console. You will be provided with an ID for each API that is configured in the console.
For retrofit users
- Add AppticsAnalyticsApiTrackingInterceptor to your Okhttp client builder used to make API calls.
Copied
- Add TrackApiWith annotation to the API interface method, with the corresponding API ID provided in the web console.
Copied
For users using other networking libraries
- Use startTrackApi method with the API ID and the request method (GET, POST, PUT, etc.) before making network call.
Copied
- startTrackApi will return a tracking id. Use that id along with the API response code (200, 400, etc.) in the endTrackApimethod. Call endTrackApi method once the API has returned the response.
Copied