Enhanced User Interaction Traces in New Relic Mobile

At the end of 2013 New Relic introduced User Interaction Traces—a feature unlike anything seen before. Interaction Traces allows you to get activity timeline views for different events in your mobile applications in production. Over the past few months we’ve collected feedback from you, our customers, on how you use Interaction Traces, and today we are proud to announce a number of improvements to User Interaction Traces based on that feedback.

The following improvements have been made to User Interaction Traces in the iOS and Android agents:

  • Interaction name scheme improvements
  • Exclusive interactions
  • Renaming default interactions
  • Interaction history
  • Manual interaction completion
  • Additional changes to the custom interactions API in NewRelic.h (iOS) and NewRelic.java (Android).

Exclusive interactions

Our first inception of Interaction Traces were intentionally non-discrete, i.e. once an interaction started, it would stop only when there was no more data to collect. This resulted in activity from many view controllers being rolled up under a single interaction. This was confusing because the interaction naming (such as UIViewController#viewDidLoad or Activity#OnCreate) would imply the data therein would be related only to the view controller named. Exclusive Interactions is our solution to this confusion. Interactions will no longer roll up together—each view controller will have its own interaction.

Prior to Exclusive Interactions, SecondViewController was quickly pushed after FirstViewController and the trace data was rolled up into FirstViewController:

Exclusive Interactions

With Exclusive Interactions, FirstViewController and SecondViewController are separated into their own interactions:



Naming scheme improvements

We originally designed Interactions Traces to be named based on the view controller and method they were started from, such as UIViewController#viewDidLoad (iOS) or Activity#onCreate (Android), but, depending on the state of your view controller the interaction could start from either the viewDidLoad/onStart method or viewWillAppear:/onResume method. This ended up creating two separate interaction traces: UIViewController#viewDidLoad/Activity#onCreate and UIViewController#ViewWillAppear:/Activity#onResume. This was a somewhat arbitrary split of data that should have been tightly coupled. We’ve solved this by simply basing the interaction naming scheme on only the view controller and not the methods it starts from. Interactions now have clear and consist naming:

user interaction screenshot

Renamed default interactions

By default, any interaction trace that is automatically instrumented will have the name scheme as shown above (“Display ViewController”). On iOS, this default naming scheme can be overridden by extending ViewController with @protocol NewRelicCustomInteractionInterface, and implementing the protocol method:

- (NSString*) customNewRelicInteractionName
return @”My Custom Interaction Name”;

(Note that this feature already existed in the Android agent. An interaction can be renamed by calling void setInteractionName(String name) defined in NewRelic.java.)

Interaction Trace history

The iOS and Android agents now track Interaction Trace history. This allows the viewing of an interaction that occurred directly prior to any interaction you are viewing, providing more context for the data.

NewRelic.h custom API methods

With the changes to the Interaction Trace naming scheme, some of the custom API methods needed to be updated. To accommodate the new naming scheme, we’ve added the following method:

NewRelic.h (iOS):

+ (NSString*) startInteractionWithName:(NSString*)name;

NewRelic.java (Android):
public static String startInteraction(String actionName);

This method allows the start of an Interaction Trace with a custom name. It returns a unique identifier called interactionIdentifier that can be used to manually stop that unique Interaction Trace.

The following methods have been deprecated:

NewRelic.h (iOS): 

+ (NSString*) startInteractionFromMethodName:(NSString*)selectorName




+ (NSString*) startInteractionFromMethodName:(NSString*)selectorName





+ (NSString*) startInteractionFromMethodName:(NSString*)selectorName




NewRelic.java (Android): 

public static String startInteraction(Context activityContext,

String actionName); 

public static String startInteraction(Context context,

String actionName,

boolean cancelRunningTrace);

We recommend replacing all occurrences of these methods with the new method.

Manual interaction completion

Now that Interaction Traces are more discrete (individually separate and distinct) we wanted to provide a way to complete an Interaction Trace through the custom API. Defined in NewRelic.h and NewRelic.java:

NewRelic.h (iOS):

+ (void) stopCurrentInteraction:(NSString*)interactionIdentifier;

NewRelic.java (Android):

public static void endInteraction(String id);

This method will complete the Interaction Trace associated with the interactionIdentifier (This value is returned by the startInteraction:... mentioned above.) It’s possible that the associated interaction may have already self-completed since it still follows the default rules of completing after 0.5 seconds of inactivity.

We develop these features to give you better leverage over your data, so the more feedback we get from you, the more we can improve them. To provide feedback and for any questions or comments please visit our community forums.

And if you haven’t already installed New Relic Mobile into your iOS or Android apps, download and install it today and get a free 30-day trial of our enterprise feature set.


Bryce Buchanan is an iOS Engineer on the Mobile Agent team at New Relic. Prior to joining New Relic, he designed and build iOS applications for a small company in Seattle with over 30 app accepted to the AppStore. View posts by .

Interested in writing for New Relic Blog? Send us a pitch!