Custom attributes vs. Custom events
The New Relic Mobile agents collect a wide variety of information from your app in the form of Event data which can be found in Insights. Along with this default information, the agents’ API allows you to add some preset attributes like
userId as well as custom events and attributes.
What information is recorded in Insights by default?
The Mobile agents send some default event data from your mobile app to Insights, such as data about interactions, sessions, crashes, and request errors. For a list of these event types and attributes please check out the Mobile events and attributes doc.
When should we use custom attribute or custom event?
Custom attribute is added as a session attribute. The session attributes copy to all events (including default and custom events) which are created during the session. If you want to record any information during a session to all events, you can use custom attributes.
These custom attributes should be something that doesn’t change through the session such as if a user authenticated through saml, free account vs paid account, or if items were left in a cart from the last session.
For custom event, the agent will create a new event type. This is helpful if you are trying to record an action or a feature of the app that includes a few attributes that don’t relate to any default events. For example, a purchase action may include product id, product name, price and etc.
How to record custom attributes or events?
To record custom attribute, use
setAttributeAPI. We have some great documentations on how to use the API and provided some good examples:
To record custom events, use
recordCustomEventAPI. Below is some helpful docs:
Where to find custom attributes or events?
Feel free to share your use cases or questions about this by replying this post.