Skip to main content
Version: 1.0.0

Track Feature Failures in iOS

Type: 7 | Default Severity: Major (see severity)

Feature tracking is especially useful for monitoring flows (such as chat, payments, or onboarding) by chaining two functions and ensuring each step completes as expected.

This guide explains how to implement feature tracking in your iOS app, using a chat feature as an example. The same approach can be applied to any feature flow where the successful execution of one function depends on another.

1. Identify Feature Functions

Determine the functions that represent the start and end of your feature. For example, in a chat feature:

  • sendChat is called when the user taps the Send button.
  • onChatSent is called after the message is successfully sent.

2. Instrument Functions with Ax.start() and Ax.end()

Use Ax.start() and Ax.end() APIs to mark the beginning and end of each function. Chain the functions using nextFunctionSignature and inClass fields of the Observer class in the first function. Set the expectedChainedExecutionTime to define the maximum allowed time between the two function calls.

#import <AppxiomCore/Observer.h>
#import <AppxiomCore/Ax.h>

- (void) sendChatClicked:(UITapGestureRecognizer *)recognizer {
[self sendChat:chatMessage];
}

- (Boolean) sendChat:(NSString *) message {
// Chain to 'onChatSent:' with a 10-second window
Observer *observer = [[[Ax observeWithCurrentFunctionSignature:@selector(sendChat:) inClass:[self class]] expectedChainedExecutionTime:10000] nextFunctionSignature:@selector(onChatSent:) inClass:[self class]];

[Ax start:observer withParams:[NSArray arrayWithObjects:message]];

if([self isValid:message]){
[self syncMessage:message];
[Ax end:observer withReturnValue:true];
return true;
}

[Ax end:observer withReturnValue:false];
return false;
}

- (void) onChatSent:(NSString *)chatMessageId {
Observer *observer = [Ax observeWithCurrentFunctionSignature:@selector(onChatSent:) inClass:[self class]];
[Ax start:observer withParams:[NSArray arrayWithObjects:chatMessageId]];
[self chatSyncConfirmed:chatMessageId];
[Ax end:observer];
}

Key Points

  • Chain functions using nextFunctionSignature and inClass in the first function's Observer.
  • expectedChainedExecutionTime sets the allowed time (in ms) for the second function to execute after the first. Default is 2000 ms.
  • If the second function is not called within the expected time, an issue is reported to the dashboard.

Best Practices

  • Always use Ax.start() and Ax.end() for both functions in the chain.
  • Set a realistic expectedChainedExecutionTime based on your feature's expected latency.
  • Regularly review the dashboard for reported issues and adjust thresholds as needed.

Frequently Asked Questions (FAQ)

Q: What is feature tracking in Appxiom?
A: Feature tracking allows you to monitor flows in your app by chaining functions and detecting if any step fails or takes too long.

Q: What happens if the second function is not called within the expected time?
A: An issue is reported to the Appxiom dashboard, helping you identify and resolve bottlenecks or failures in your feature flow.

Q: How do I choose the right expectedChainedExecutionTime?
A: Set it based on the typical latency of your feature. The default value is 2000 ms but strongly suggest to adjust as needed based on real-world performance.

Q: Will this impact app performance?
A: The overhead is minimal. Feature tracking is designed to be lightweight and should not noticeably affect app performance.

Q: Where can I view reported feature failures?
A: All issues are visible in the Appxiom dashboard, categorized by feature and severity.