Skip to content

Feature/reactnative sourcemap upload#478

Open
ndesai-newrelic wants to merge 7 commits intodevelopfrom
feature/reactnative-sourcemap-upload
Open

Feature/reactnative sourcemap upload#478
ndesai-newrelic wants to merge 7 commits intodevelopfrom
feature/reactnative-sourcemap-upload

Conversation

@ndesai-newrelic
Copy link
Copy Markdown
Contributor

No description provided.

ywang-nr and others added 3 commits March 19, 2026 10:11
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 ywang-nr self-requested a review March 31, 2026 15:19
@ywang-nr
Copy link
Copy Markdown
Contributor

PR will wait when PROD will ready, remember to keep updating to base

ywang-nr and others added 2 commits March 31, 2026 15:18
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.
@ndesai-newrelic ndesai-newrelic force-pushed the feature/reactnative-sourcemap-upload branch from 82773ef to 0e409aa Compare March 31, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants