• /
  • EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

Monitor your Cordova mobile app

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:

(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)

  1. Go to one.newrelic.com > Browser & Mobile > (choose Android or iOS), then complete the instrumentation steps in the UI.
  2. 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:

bash
$
# 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 and false. Defaults to true.
  • DISTRIBUTED_TRACING_ENABLED: Enable or disable the adding of distributed tracing headers to network requests.

    • Possible values are true and false. Defaults to true.
  • 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 and false. Defaults to true.
  • 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 and false. Defaults to true.
  • LOGGING_ENABLED: Enable or disable agent logging.

    • Possible values are true and false. Defaults to true.
  • LOG_LEVEL: Specifies the log level.

    • Possible values are ERROR (least verbose), WARNING INFO, VERBOSE, DEBUG, AUDIT (most verbose).
    • Defaults to INFO on Android and WARNING on iOS.
  • WEB_VIEW_INSTRUMENTATION (iOS ONLY): Enable (default) or disable automatic WKWebView instrumentation.

    • Possible values are true and false. Defaults to true.
  • 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 and false. Defaults to false.
  • OFFLINE_STORAGE_ENABLED: Enable or disable offline data storage when no internet connection is available.

    • Possible values are true and false. Defaults to true.
  • NEW_EVENT_SYSTEM_ENABLED: Enable or disable to use our new, more stable, event system for iOS agent.

    • Possible values are true and false. Defaults to true.
  • BACKGROUND_REPORTING_ENABLED: Enable or disable Background Events Reporting when the app is in the background.

    • Possible values are true and false. Defaults to false.

    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"

(Ionic Cordova only) Configure your Ionic framework

If you're using an ionic framework, add this to your Cordova project directory:

bash
$
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.

Record breadcrumbs

Track a method as an interaction.

Start interactions

Stop interactions

Record errors

Record errors

Record custom metrics.

Record custom metrics

Record custom attributes and events.

There are several ways to report custom attributes and events:

Track custom network requests and failures.

Track HTTP requests

Track failing HTTP requests

Shut down the agent.

Shut down the agent

Enable/disable default mobile monitoring settings.

Enable/disable monitoring features

Run a test crash report.

Test crash reporting

Update the agent

To update your Cordova agent version, run this simple command:

bash
$
cordova plugin update
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.