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

Configure the React Native agent for EAS Build

If you build your React Native app with EAS Build, Expo's Continuous Native Generation (CNG) regenerates your android/ and ios/ folders from scratch on every expo prebuild step — both locally and on EAS's build servers. That means a manually added newrelic.properties file or a hand-added Xcode Run Script build phase gets wiped out on the next build.

The newrelic-react-native-agent config plugin solves this by regenerating the New Relic build configuration on every prebuild, so Android mapping file and source map upload and iOS dSYM and source map upload keep working across EAS builds. The plugin reads credentials from environment variables at build time and never commits them to your repo.

ヒント

This page assumes you've already installed the React Native agent and added the config plugin to your app.json or app.config.js, as described in Integrate with Expo. It requires a recent version of newrelic-react-native-agent — check the package's GitHub releases if the plugin options below aren't available yet.

Before you begin

Get the following from the same New Relic account:

  • A User API key.
  • Your Android and/or iOS application token (the same token you pass to NewRelic.startAgent()). If you ship to both platforms, you'll need one token per platform.

Set EAS environment variables

Register your User API key and application token(s) as EAS environment variables, scoped to the environments you build with:

bash
$
eas env:create --environment production --name NEWRELIC_USER_API_KEY --value <YOUR_USER_API_KEY> --visibility sensitive
$
eas env:create --environment production --name NEWRELIC_ANDROID_APP_TOKEN --value <YOUR_ANDROID_APP_TOKEN> --visibility sensitive
$
eas env:create --environment production --name NEWRELIC_IOS_APP_TOKEN --value <YOUR_IOS_APP_TOKEN> --visibility sensitive

重要

Don't use --visibility secret. EAS reserves secret-visibility variables for its own credential system, so EAS never exposes them as process.env to build scripts — the config plugin won't see them, and it'll silently skip writing the Android properties file or the iOS build phase credentials. Use plaintext or sensitive instead.

EAS Build resolves plaintext/sensitive variables before running prebuild, whether the build runs on EAS's servers or locally with eas build --local.

Android: Automatic mapping file and source map upload

With no extra configuration, the plugin reads your User API key from NEWRELIC_USER_API_KEY and your Android application token from NEWRELIC_ANDROID_APP_TOKEN, and writes them into android/app/newrelic.properties on every prebuild:

{
"name": "my app",
"plugins": ["newrelic-react-native-agent"]
}

Those properties are what the agent's newrelicMapUploadRelease and newrelicReactNativeSourceMapUploadRelease Gradle tasks read to authenticate the upload of your ProGuard/R8 mapping file and React Native source map after each release build. For more on how that upload works (and how to upload manually if needed), see React Native JavaScript error reporting.

If only one of the two environment variables is set, the plugin still writes that single property, and the Gradle task logs which one is missing rather than failing the build. If neither is set, the plugin leaves newrelic.properties untouched and both tasks skip the upload with a log message.

Use custom environment variable names (Android)

To source the key and token from differently named environment variables, pass them explicitly:

{
"name": "my app",
"plugins": [
[
"newrelic-react-native-agent",
{
"android": {
"apiKeyEnvName": "MY_NR_USER_API_KEY",
"appTokenEnvName": "MY_NR_ANDROID_APP_TOKEN"
}
}
]
]
}

iOS: Automatic dSYM and source map upload

Unlike on Android, the dSYM and React Native source map upload scripts (run-symbol-tool and upload-react-native-sourcemap, from the dsym-upload-tools folder) don't ship inside the NewRelicAgent CocoaPod, and normally require a Run Script build phase added by hand in Xcode — which doesn't survive expo prebuild regenerating ios/. On every prebuild, the plugin instead:

  • Copies both scripts into ios/dsym-upload-tools.
  • Adds a Run Script build phase named "Upload dSYMs and Source Maps to New Relic" (after "Bundle React Native code and images") that invokes them, reading credentials from environment variables at build time — the generated script only references the credentials by name and never writes them to a file.
  • Makes sure the "Bundle React Native code and images" phase exports SOURCEMAP_FILE, since Expo's default template doesn't set it and Expo wouldn't otherwise generate the source map.

With no extra configuration, the build phase reads your iOS application token from NEWRELIC_IOS_APP_TOKEN and your User API key from NEWRELIC_USER_API_KEY (shared with the Android default):

{
"name": "my app",
"plugins": ["newrelic-react-native-agent"]
}

For background on what these scripts do and how dSYM upload works outside of Expo, see Upload dSYMs.

ヒント

Both scripts only run for Release builds and skip simulator builds by default. To test the source map upload path on a simulator, set NEWRELIC_SOURCEMAP_ALLOW_SIMULATOR=true.

Use custom environment variable names (iOS)

To source the token and key from differently named environment variables, pass them explicitly:

{
"name": "my app",
"plugins": [
[
"newrelic-react-native-agent",
{
"ios": {
"appTokenEnvName": "MY_NR_IOS_APP_TOKEN",
"apiKeyEnvName": "MY_NR_USER_API_KEY"
}
}
]
]
}

Verify the upload

After running an EAS build, check the build logs for each platform:

  • Android: Look for the newrelicMapUploadRelease and newrelicReactNativeSourceMapUploadRelease Gradle tasks in the log. A successful run reports the mapping file and source map were found and uploaded, with no missing-config warnings.
  • iOS: Look for the "Upload dSYMs and Source Maps to New Relic" run script step. If a credential is missing, it logs which one and skips that upload (for example, NEWRELIC_IOS_APP_TOKEN not set, skipping...) rather than failing the build. When credentials are present, it logs that it's processing the dSYMs and source map and uploading them to New Relic.

Once a build succeeds, confirm the source map actually landed in New Relic by checking List and delete React Native source maps.

Troubleshoot

Copyright © 2026 New Relic株式会社。

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