Feature/reactnative sourcemap upload#478
Open
ndesai-newrelic wants to merge 7 commits intodevelopfrom
Open
Conversation
Fix the issue that artifacts are missing for monoenabled build
Co-authored-by: ywang-nr <84047247+ywang-nr@users.noreply.github.com>
This commit introduces automated support for uploading React Native source maps to the New Relic Symbol Ingest API during the Android build process.
Key changes include:
* **New Gradle Task**: Added `NewRelicReactNativeSourceMapUploadTask` which identifies, validates, and uploads JavaScript source maps. It is designed to run after React Native bundle tasks (e.g., `bundleReleaseJsAndAssets`).
* **Source Map Management**: Introduced the `ReactNativeSourceMap` class to handle the logic of reading `newrelic.properties`, configuring API endpoints (including regional support), and performing multipart form uploads of the source map files.
* **Project Detection**: Enhanced `BuildHelper` to automatically detect React Native projects by searching for `react.gradle` or specific React Native bundle tasks.
* **Plugin Integration**:
* Updated `VariantAdapter` to wire the upload task into the Android Gradle Plugin (AGP) lifecycle for compatible variants.
* Added support across multiple AGP versions (AGP 4, 7, and 9) via their respective adapters.
* Added a new extension property `reactNativeSourceMapUploadEnabled` to allow users to toggle this feature.
* **Configuration**: Supports configuration via `newrelic.properties` for app tokens, API keys, and custom upload hosts.
* **Testing**: Added comprehensive integration and unit tests for the new task, configuration fetching, and multipart upload logic.
ywang-nr
approved these changes
Mar 31, 2026
Contributor
|
PR will wait when PROD will ready, remember to keep updating to base |
This commit introduces a mechanism to handle React Native source maps that exceed the 200MB server size limit by sending telemetry data instead of the full file upload.
Key changes include:
* **Size Limit Enforcement**: Added `MAX_COMPRESSED_SIZE` (200MB) constant. The agent now checks the compressed size of the source map before attempting an upload.
* **Telemetry Fallback**: Introduced `sendTelemetryOnly` which sends a POST request with a new `x-telemetry-data` header. This header contains a Base64-encoded JSON payload describing the oversized bundle and source map.
* **JS Bundle Detection**: Added logic to locate the `index.android.bundle` file to include its size in the telemetry report.
* **Refactoring**:
* Extracted response code handling into a private `handleResponse` method to reduce duplication between standard uploads and telemetry-only requests.
* Updated `sendSourceMap` to use the new size validation and response handling logic.
* **JSON Generation**: Added `buildTelemetryJson` and `escapeJsonString` to manually construct the telemetry payload without adding external dependencies.
* **Testing**: Added unit tests to verify JSON structure, bundle name parsing, and the 200MB size limit constant.
82773ef to
0e409aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.