Track Feature Failures in Android Apps
Appxiom SDK enables you to track feature failures in your Android app by monitoring the execution of chained functions within a single app session. This helps you detect when a critical feature, such as Add to Cart does not complete as expected, allowing you to quickly identify and resolve reliability issues.
Overview of Feature Failure Tracking
What is Feature Failure Tracking?
- Chained Function Monitoring: Track the execution of two related functions that together define the start and end of a feature.
- Automatic Issue Reporting: If the second function in the chain is not executed within the expected time, an issue is automatically reported.
- Customizable Timing: Set the expected time window for chained execution using the
expectedChainedExecutionTimefield in the annotation.
Benefits
- Detect and diagnose incomplete or failed feature flows
- Improve app reliability and user experience
- Gain visibility into real-world feature performance
- Works with any feature that can be represented by chained function calls
Step 1: Identify Feature Functions
Choose the functions that represent the start and end of a feature (e.g., addItemToCart and onItemAddedToCart).
Step 2: Annotate and Chain Functions
- Annotate both functions with
@AX. - In the first function, use
nextFunctionIdandnextFunctionClassto point to the second function. - Set
expectedChainedExecutionTimeto define the maximum allowed time between executions (default: 2000 ms).
Step 3: Use Ax.start() and Ax.end()
Wrap both the functions with Ax.start() and Ax.end() and annotate with @AX to enable tracking.
- Java
- Kotlin
public class ProductListingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_listing);
addToCartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addItemToCart(item.getId());
}
});
}
// 'onItemAddedToCart' is expected to be called within 5000 ms.
@AX(nextFunctionId = "onItemAddedToCart",
nextFunctionClass = ProductListingActivity.class,
expectedChainedExecutionTime = 5000)
public boolean addItemToCart(String itemId){
Ax.start(new Object(){}, itemId);
if(isValid(itemId)){
...
...
return true;
}
return Ax.end(new Object(){}, false);
}
@Override
public void onApiCallComplete(JSONObject response){
if(validResponse(response)){
onItemAddedToCart(response.getString("id"));
}
}
@AX
public void onItemAddedToCart(String itemId){
Ax.start(new Object(){}, itemId);
showMessage(Messages.CARTED_SUCCESS);
Ax.end(new Object(){});
}
}
class ProductListingActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_product_listing)
...
...
addToCartButton.setOnClickListener {
addItemToCart(item.getId())
}
}
// 'onItemAddedToCart' is expected to be called within 5000 ms.
@AX(nextFunctionId = "onItemAddedToCart",
nextFunctionClass = ProductListingActivity::class,
expectedChainedExecutionTime = 5000)
fun addItemToCart(itemId: String): Boolean {
Ax.start(object {}, itemId)
if(isValid(itemId)){
...
...
return true
}
return Ax.end(object {}, false)
}
override fun onApiCallComplete(response: JSONObject) {
if(validResponse(response)){
onItemAddedToCart(response.getString("id"))
}
}
@AX
fun onItemAddedToCart(itemId: String) {
Ax.start(object {}, itemId)
showMessage(Messages.CARTED_SUCCESS)
...
...
Ax.end(object {})
}
}
Key Points to Remember
- Both functions must be annotated with
@AX. - Chain the functions using
nextFunctionIdandnextFunctionClassin the first function. expectedChainedExecutionTimesets the allowed time window (default: 2000 ms).- Use
Ax.start()andAx.end()in both functions to wrap the logic for tracking.
@AX Annotation Fields
- nextFunctionId: Name/ID of the second function to chain.
- nextFunctionClass: Class where the second function is defined.
- expectedChainedExecutionTime: Maximum time (ms) allowed between executions before an issue is reported.
Best Practices
- Use feature tracking for critical flows (e.g., checkout, login, payments).
- Set realistic
expectedChainedExecutionTimevalues based on real user scenarios. - Regularly review reported issues to improve feature reliability.
- Document all tracked features for your QA and development teams.
Frequently Asked Questions (FAQ)
Q: What is feature failure tracking?
A: It monitors the execution of chained functions representing a feature and reports if the expected flow is not completed in time.
Q: Can I track any feature in my app?
A: Yes, as long as the feature can be represented by two chained functions.
Q: What happens if the second function is not called in time?
A: The SDK will automatically report a feature failure issue to the Appxiom dashboard.
Q: Do both functions need to be annotated with @AX?
A: Yes, both the start and end functions must be annotated for tracking to work.
Q: Can I set a custom time window for chained execution?
A: Yes, use the expectedChainedExecutionTime field in the annotation.
Q: Why is my feature failure not being reported?
A: Ensure both functions are properly annotated, chained, and wrapped with Ax.start() and Ax.end().