• /
  • Log in
  • Free account

Report mobile monitoring custom events and attributes

Mobile monitoring in New Relic sends some default event data from your mobile app to New Relic, such as data about interactions, sessions, crashes, and request errors. You can also create your own custom attributes and events for more detailed querying and analysis.

Create custom attributes and events

You can create custom session-level attributes for default mobile monitoring events using the mobile agent SDKs. For example, to record a username attribute for some part of your iOS or Android app, you would use the setAttribute API (Android | iOS). These attributes are session-related information and are shared by multiple mobile event types.

You can also create entirely new custom event types and assign them their own custom attributes, using the recordCustomEvent API (Android | iOS).

To help with crash analysis, you can use the SDK to create MobileBreadcrumb and MobileHandledException events. These events are available for querying and also displayed in the crash event trail UI.

For more on creating custom attributes and custom events, see:

Mobile event and attribute query examples

Here are some examples of using NRQL to query your mobile app events and attributes:

Size limits and restricted characters

Limits for custom attributes added to default mobile events:

  • Attributes: 128 maximum
  • String attributes: 4 KB maximum length (empty string values are not accepted)

Limits for custom events:

  • Attributes: 254 maximum per event (number includes default session attributes)
  • String attributes: 4 KB maximum length (empty string values are not accepted)

Naming syntax and rules: See Rules for custom data.

Set the time to send data

By default, New Relic transmits event data in any of these situations:

  • A session has been ongoing for 600 seconds.
  • The app session ends by backgrounding.
  • The app crashes.

If the app crashes, New Relic gathers the attributes and events for that session and sends them to Insights. (On iOS, this happens the next time the app is launched). You can then use Insights to query and analyze the event and attribute data.

To set the maximum time (in seconds) that the agent will store events in memory, use the following SDK calls:

  • iOS method:

    + (void) setMaxEventBufferTime:(unsigned int)seconds;
  • Android method:

    public static void setMaxEventBufferTime(int maxBufferTimeInSec);

Privacy considerations

If you want to collect personal data via custom attributes, please consult with your privacy or legal teams. Be sure to follow your organization's obligations for notices and consent regulations.

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.