Our New Relic Cordova agent monitors your Cordova mobile app and provides deep insights into your app's performance, errors, and user experience. The agent includes all New Relic mobile monitoring features we offer for native mobile apps. Once you install and configure the Cordova agent, you'll be able to:
- Capture JavaScript errors Identify and fix problems quickly.
- Track network requests: See how your app interacts with the backend.
- Use distributed tracing: Drill down into handled exceptions and find the root cause.
- Create custom events and metrics: Understand how your users interact with your app.
Compatibility requirements
Before you install the Cordova agent, ensure your app meets these requirements:
- Cordova 7.x or higher
- Node.js 6.0 or higher
- Cordova CLI tools
- An Android or iOS Cordova platform for your project
- Mobile application tokens
(Recommended) Guided installation
To install the Cordova agent, follow our guided install, located directly in the UI.
Manual installation
If you need to install the agent manually, follow these steps:
Create an application token(s)
- Go to one.newrelic.com > Browser & Mobile > (choose Android or iOS), then complete the instrumentation steps in the UI.
- From Step 4 in the UI, copy the application token(s) (one for iOS and Android if applicable).
Add the Cordova agent
In your Cordova project directory, add the Cordova agent to your project using your command line tool, and paste the application token(s) in the --variable
argument:
$# Install from github repository$cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="YOUR_IOS_APP_TOKEN" --variable ANDROID_APP_TOKEN="YOUR_ANDROID_APP_TOKEN"
(Optional) Configure the agent
Add the following optional configurations to the --variable
argument, which will call them upon agent start:
CRASH_REPORTING_ENABLED
: Enable or disable crash reporting.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
DISTRIBUTED_TRACING_ENABLED
: Enable or disable the adding of distributed tracing headers to network requests.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
INTERACTION_TRACING_ENABLED
: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. This will disable default and custom interactions.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
DEFAULT_INTERACTIONS_ENABLED
: Enable or disable default interactions. Trace instrumentation still occurs, but no traces are harvested. This will enable or disable default interactions only while custom interactions remain enabled.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
LOGGING_ENABLED
: Enable or disable agent logging.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
LOG_LEVEL
: Specifies the log level.- Possible values are
ERROR
(least verbose),WARNING
INFO
,VERBOSE
,DEBUG
,AUDIT
(most verbose). - Defaults to
INFO
on Android andWARNING
on iOS.
- Possible values are
WEB_VIEW_INSTRUMENTATION
(iOS ONLY): Enable (default) or disable automatic WKWebView instrumentation.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
COLLECTOR_ADDRESS
: Specifies the URI authority component of the harvest data upload endpoint.CRASH_COLLECTOR_ADDRESS
: Specifies the authority component of the crash data upload URI.FEDRAMP_ENABLED
: Enable or disable reporting data using different endpoints for US government clients.- Possible values are
true
andfalse
. Defaults tofalse
.
- Possible values are
OFFLINE_STORAGE_ENABLED
: Enable or disable offline data storage when no internet connection is available.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
NEW_EVENT_SYSTEM_ENABLED
: Enable or disable to use our new, more stable, event system for iOS agent.- Possible values are
true
andfalse
. Defaults totrue
.
- Possible values are
BACKGROUND_REPORTING_ENABLED
: Enable or disable Background Events Reporting when the app is in the background.- Possible values are
true
andfalse
. Defaults tofalse
.
These options are only available on Cordova agent v6.2.1 and higher.
For example, if you wanted to disable crash reporting, call the following:
bash$cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="YOUR_IOS_APP_TOKEN" --variable ANDROID_APP_TOKEN="YOUR_ANDROID_APP_TOKEN" --variable CRASH_REPORTING_ENABLED="false"- Possible values are
(Ionic Cordova only) Configure your Ionic framework
If you're using an ionic framework, add this to your Cordova project directory:
$ionic cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="YOUR_IOS_APP_TOKEN" --variable ANDROID_APP_TOKEN="YOUR_ANDROID_APP_TOKEN"$npm install @awesome-cordova-plugins/newrelic
Make sure you paste your application token(s) into appToken = ""
in the code above. If you deployed your hybrid app to both iOS and Android platforms, you'll need to add two separate tokens: one for iOS and one for Android.
Deploy your app
Then, deploy your app. After some app activity, you should see data in New Relic (it may take a few minutes after deploying your app).
Customize the agent instrumentation
Need to customize your agent instrumentation? Our public mobile SDK API methods let you collect custom data, configure default settings, and more.
The following customizations are available for the Cordova agent.
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. | |
Record errors | |
Record custom metrics. | |
Record custom attributes and events. | There are several ways to report custom attributes and events:
|
Track custom network requests and failures. | |
Shut down the agent. | |
Enable/disable default mobile monitoring settings. | |
Run a test crash report. |
Update the agent
To update your Cordova agent version, run this simple command:
$cordova plugin update