Introduction to New Relic for Cordova

The official New Relic Cordova plugin for iOS and Android allows developers to easily embed the New Relic Mobile agents into Cordova applications. Written in JavaScript, the plugin automatically includes New Relic's native agents to provide mobile monitoring and performance visibility.

Features

The New Relic Cordova plugin will:

  • Detect the platforms added to your Cordova application and apply the most recent release of the appropriate New Relic Mobile agent (Android or iOS).
  • Add post-build scripts for uploading iOS symbolication files.
  • Upload Android Proguard mapping files.
  • Automatically instrument mobile applications built via Cordova.

For more information, see New Relic Cordova Plugin on Github.

Compatibility and requirements

The New Relic Cordova plugin requires:

  • Cordova 7.x or higher
  • Node 6.0 or higher
  • Cordova CLI tools
  • An Android or iOS Cordova platform for your project
  • New Relic Mobile application tokens

Network requests are only recorded on iOS devices for webviews and native frameworks. Android only records native network calls.

Cordova will typically handle exceptions by default. New Relic Mobile for Cordova will record uncaught exceptions (crashes) that Cordova does not handle.

Install the Cordova plugin

Before installing, make sure you have fulfilled the prerequisites for adding the Android or iOS platform to your Cordova project. Then follow these steps to install the Cordova plugin:

  1. If you do not already have a New Relic account, create a free trial for mobile apps, then add an application from your account page.
  2. If applicable, use separate application tokens for iOS and Android.
  3. From your New Relic applications page, copy the application tokens for the Cordova platforms you are building on.
  4. Change to your Cordova project directory, then add the plugin to your project with the Cordova command line tool. Use the --variable argument to pass application tokens to the plugin:

    # Install from github repository
    cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ios-app-token}" --variable ANDROID_APP_TOKEN="{android-app-token}"
  5. Deploy your app.
  6. View your performance data from the New Relic Mobile UI.

Update the plugin

Easily update the New Relic Cordova plugin to the latest released version using the following command:

cordova plugin update

Default Cordova attributes

New Relic Mobile for Cordova includes the following attributes:

Attribute Description
appId A unique identifier for the monitored app. For example, 35091.
appBuild

Indicates the technical build number of the binary that crashed. As a developer, you can use this attribute to see exactly which build of your app crashed.

appName The name of the monitored app. For example, New Relic iOS.
appVersion

The version number of the monitored app. For example, 2.2.9.

appVersionId A New Relic unique version number of the monitored app.
architecture The processor architecture of the device such as armv7, arm64.
asn The Autonomous System Number which the device was associated with when the data was reported.
asnOwner The telecom owner of the ASN.
carrier The mobile network over which the app transferred data, such as WiFi, Verizon, Sprint, etc.
category The type of Mobile data being collected. The standard categories are Session, Interaction, and Crash. If you've added custom events via the API, they use the Custom category.
city The city where the monitored app is located, such as Portland or Seattle.
countryCode The country where the monitored app is located. For example, GB for the United Kingdom. For a list of country codes, see ISO 3166-1 alpha-2.
crashException

The exception associated with the crash, if one is present. For example, java.lang.NullPointerException.

crashMessage The message associated with the crash, if one is present.
device The name of the device, such as iPad Air or Galaxy S5.
deviceGroup The category of the device, such as iPod Touch or iPad.
deviceManufacturer The manufacturer of the device. For example, Motorola or HTC.
deviceModel The model number of the device. For example, XT1039 or SM-G900F.
interactionDuration The total time, in seconds, for the interaction to render on the device. In addition to render time, this usually includes all external calls associated with the interaction.
install If TRUE, this session was from a fresh app install.
lastInteraction The last interaction before a crash event, if one is present. For example, App Launch.
memUsageMb The total amount of memory, in MB, used by the application. Updated every 60 seconds.
name The name of the interaction associated with the event. For example, ApplicationsListFragment or NavigationDrawerFragment.
newRelicVersion The version number of the agent running on the application. For example, 4.232.0.
osMajorVersion The simplified version number of the app's host operating system, such as iOS 7, as compared to iOS 7.0.4.
osName The name of app's host operating system, for example, iOS or Android.
osVersion The exact version number of the app's host operating system, such as iOS 7.0.4, as compared to iOS 7.
regionCode The specific region within a country where the monitored app is located. In the United States, regions are states.
sessionDuration

The length of time for which the user used the application in seconds. If the session crashes, sessionDuration is not captured (although other events and attributes are still recorded).

For sessions longer than 10 minutes, events in the Interaction and Custom event categories are sent to Insights while the session is ongoing, and therefore do not have sessionDuration attributes. Events recorded near the end of the session will include the duration, as will the Session event category.

sessionId A unique identifier for a single user session.
timeSinceLastInteraction The time, in seconds, since the interaction before a crash event.
timeSinceLoad The time, in seconds, from the beginning of the mobile session to the time the event occurred. The event can be a built-in event category of Session, Interaction or Crash, as well as any Custom events sent via the agent API.
upgradeFrom When an upgrade is detected, specifies the version number of the old version from which the user upgraded. For example, 2.2.8. For the current version number, use the version attribute.
uuid A unique identifier for a specific installation of the app on a particular device, such as B8B0BC30-0235-11E4-9191-0800200C9A66.

For more help

Recommendations for learning more: