• /
  • Log in

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 events using the New Relic Mobile SDK. 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 Mobile crash event trail.

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.

Deprecated methods

As of Android agent version 5.12.0 and iOS agent version 5.12.0, use the recordCustomEvent method to create custom events. The recordEvent methods for Android and iOS are deprecated.

The deprecated recordEvent events do not have their own event type; they are recorded as a Mobile event type with a category attribute value of custom. recordCustomEvent creates an event with an eventType you can assign. But the eventType should only be used for one or two high-level event types, not for naming events. For example, you might have one event type Gestures, with many different names under that one type. For more context on this, see the recordCustomEvent query example.

For more help

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

Create issueEdit page
Copyright © 2021 New Relic Inc.