Use the New Relic mobile SDK API calls to customize and extend the data your mobile app reports to New Relic.
While our solution offers powerful out-of-the-box data collection, you may need to customize and extend the data your mobile app reports to New Relic. For example, you can use the public SDK API calls to:
- Start and stop interaction traces from events in your mobile app
- Record custom metrics
- Send custom attributes and events
- Track network requests from libraries not supported automatically
- Set custom IDs to user sessions
Get started
- Make sure you have the latest mobile agent installed.
- Select a customization from the table below and follow the method's documentation.
Available customizations
The table below lists supported SDK methods to customize your mobile agent instrumentation. Select a method to view syntax and usage examples for each agent type.
If you want to... | Use this method |
---|---|
Record breadcrumbs to track app activity that may be helpful for troubleshooting crashes. | |
Track a method as an interaction. | Start interactions Stop interactions TipIf you use these methods, the instrumented interactions will not show up on the Interactions page, but they can be still found with a NRQL query, such as:
|
Name or rename an interaction. | |
Set your app's build ID or version to be associated with interactions. | |
Create custom metrics. | |
Report custom attributes and events. | There are several ways to report custom attributes and events:
|
Track custom network requests and failures. | |
Record a handled exception as an event, including the context of what happened. | |
Record errors. | |
Name activity for app launch time. | |
Shut down the agent. | |
Enable/disable default mobile monitoring settings. | |
Run a test crash report. |
Using the mobile SDK API
(Android) Automatically instrumented methods
Automatic instrumentation is one of the Android agent's more convenient features. However, if it interferes with the method being traced, add @SkipTrace
to the method, and the agent will skip it during compile time instrumentation.
Classes | Methods |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(iOS) Automatically instrumented methods
Automatic instrumentation is one of the iOS agent's more convenient features. It is enabled by default. To disable please configure feature flags NRFeatureFlag_DefaultInteractions
and NRFeatureFlag_InteractionTracing
.
The table below lists the automatically instrumented classes and methods in iOS agent.
Classes | Methods |
---|---|
|
|
|
|
|
|
|
|
(iOS) Sending custom attributes and events
When reporting custom attributes and events, use the SDK methods within the NewRelic
object.
Methods that return BOOL
results return YES
if they succeed, or NO
if the operation did not complete. These methods are available in versions 5.0.0 or higher of the New Relic iOS agent.
The SDK can store up to 128 user-defined custom attributes at a time. If you attempt to store more than 128 attributes, the SDK returns NO
.
When naming custom attributes, we recommend that you use the simplest format needed, such as using single word attributes and no spaces. For example, My Custom Attribute
should be formatted to myCustomAttribute
.
When naming custom metrics:
- Avoid using the characters
/
]
[
|
*
when naming things. - Avoid multi-byte characters.