Take advantage of our **Real User Monitoring (RUM) CLI** to easily upload the **source maps** for your applications to the Coralogix RUM service.

## Overview

Source map files are files commonly used in web development to facilitate the debugging process of minified or transpiled code. When JavaScript or CSS code is minified or transformed into a more compact form for production, it becomes challenging to trace errors back to the original source code due to the loss of meaningful variable names, line numbers, and structure. Source map files address this issue by providing a mapping between the minified code and its original, human-readable source code. This enables developers to debug efficiently by allowing browsers and debugging tools to display accurate error messages and stack traces based on the original code, aiding in the identification and resolution of issues in the development process.

Take advantage of our RUM CLI to easily upload the source maps for your applications to the Coralogix RUM service.

Information on how to automatically upload your source maps using the **RUM Integration Package** can be found [here](https://coralogix.com/docs/user-guides/rum/getting-started/rum-integration-package/index.md).

## Install the RUM CLI

1.

Open a terminal or command prompt.

2.

Run the following command to install the CLI globally:

```bash
npm i @coralogix/rum-cli
```

3.

Once the installation is complete, you can use the CLI by running the `coralogix-rum-cli` command in your terminal.

## API key

To use this API you need to [create](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys/index.md) a personal or team API key. It’s recommended to use permission presets, as they are automatically updated with all relevant permissions. Alternatively, you can manually add individual permissions.

| Preset        | Action                                                      | Description                                 |
| ------------- | ----------------------------------------------------------- | ------------------------------------------- |
| SourceMapping | `SOURCE-MAPPING:READMAPPING` `SOURCE-MAPPING:UPLOADMAPPING` | Read RUM Source Maps Upload RUM Source Maps |

## Commands

Here are some example commands for using the Coralogix RUM CLI:

### Upload source maps

```bash
coralogix-rum-cli upload-source-maps -k <cx_api_key> -a <application> -v <version> -f <folder_path> -e <env> -c <commit_hash> -n <repo_name> -o <org_name>
```

### Display help

```bash
coralogix-rum-cli upload-source-maps --help
```

## Uploading source maps

Three options exist for uploading source maps.

- Upload source maps during the onboarding process.
- Upload source maps from the Coralogix RUM user interface. \[**Recommended** if you didn’t upload during the onboarding process\]
- Upload source maps manually using the Coralogix RUM CLI (explained in this document).

When uploading source maps using the RUM CLI, use the following options:

| Option                           | Description                                                        |
| -------------------------------- | ------------------------------------------------------------------ |
| `k, --private-key <cx_api_key>`  | Your **API Key** to authenticate with the Coralogix API            |
| `a, --application <application>` | Name of the application                                            |
| `-v, --version <version>`        | The application version Must match the version used by the RUM SDK |
| `f, --folder-path <folder_path>` | Path to the folder containing the source maps.                     |
| `e, --env <env>`                 | Your environment                                                   |
| `c, --commit-hash <commit_hash>` | GitHub commit hash (optional)                                      |
| `n, --repo-name <repo_name>`     | GitHub repository name (optional)                                  |
| `o, --org-name <org_name>`       | GitHub organization name (optional)                                |
| `h, --help`                      | Display help                                                       |

## Upload source maps using a script

To simplify the process of uploading source maps using the Coralogix RUM CLI, you can create a bash script that automates the task. Follow these steps to set up the script for CI and non-CI integrations.

### CI integration

1.

Create a new file named `upload-source-maps.sh` and open it for editing.

2.

Copy and paste the following script into the file, replacing the placeholder values with your actual information:

```bash
#! /usr/bin/env bash

# Replace these values with your actual information
REPO_NAME="your-repo-name"
ORG_NAME="your-github-username"
APPLICATION="your-application-name"
ENV="your-environment"
SOURCE_MAPS_PATH="your-source-maps-path"
PRIVATE_KEY="your-coralogix-private-key"
VERSION="your-application-version"

# Get the commit hash using git rev-parse
COMMIT_HASH=$(git rev-parse HEAD)

# Run Coralogix RUM CLI to upload source maps
coralogix-rum-cli upload-source-maps -k "$PRIVATE_KEY" -a "$APPLICATION" -v "$VERSION" -f "$SOURCE_MAPS_PATH" -e "$ENV" -c "$COMMIT_HASH" -n "$REPO_NAME" -o "$ORG_NAME"
```

**Note:** The `$RELEASE_ID` must align with the content of the version field in your `CoralogixRum.init()` configuration in [Coralogix SDK for Browsers](https://coralogix.com/docs/user-guides/rum/sdk-installation/javascript/npm-browser/index.md).

______________________________________________________________________

### Non-CI integration

1.

Open a terminal window.

2.

Run the following command:

```text
coralogix-rum-cli upload-source-maps -k "$PRIVATE_KEY" -a "$APPLICATION" -v "$VERSION" -f "$SOURCE_MAPS_PATH" -e "$ENV" -c "$COMMIT_HASH" -n "$REPO_NAME" -o "$ORG_NAME"
```

**Note:** The `$VERSION` must align with the content of the version field in your `CoralogixRum.init()` configuration in [Coralogix SDK for Browsers](https://coralogix.com/docs/user-guides/rum/sdk-installation/javascript/npm-browser/index.md).

______________________________________________________________________

## Available environments

The Coralogix RUM CLI supports the following environments:

- EU1: https://ng-api-grpc.coralogix.com:443 (eu-west-1, Ireland).
- EU2: https://ng-api-grpc.eu2.coralogix.com:443 (eu-north-1, Stockholm).
- US1: https://ng-api-grpc.coralogix.us:443 (us-east-2, Ohio).
- US2: https://ng-api-grpc.cx498.coralogix.com:443 (us-west-2, Oregon).
- AP1: https://ng-api-grpc.app.coralogix.in:443 (ap-south-1, Mumbai).
- AP2: https://ng-api-grpc.coralogixsg.com:443 (ap-southeast-1, Singapore).
- AP3: https://ng-api-grpc.ap3.coralogix.com:443 (ap-southeast-3, Asia Pacific (Jakarta)).

Please use the appropriate environment value when specifying the `-e, --env option`.

## Optional GitHub information

Use this GitHub information to add context to your source maps.

| Option                           | Description                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `c, --commit-hash <commit_hash>` | This option allows you to provide the GitHub commit hash associated with the source maps. Including this hash can help in tracking down issues specific to a particular commit.                                                                                                                                                                    |
| `n, --repo-name <repo_name>`     | By specifying the GitHub repository name, you're indicating the repository where the source code is hosted. This information aids in correlating source maps with the correct repository.                                                                                                                                                          |
| `o, --org-name <org_name>`       | This option enables you to input your GitHub organization user, helping to attribute the source maps to the appropriate organization user. Providing these GitHub-related options can enhance the accuracy of source map management and issue tracking within Coralogix RUM. However, they are not mandatory and can be omitted if not applicable. |

## Limitations

The source map folder size limit is **100MB** and should not be exceeded.

## Additional resources

|                |                                                                                                                                                                                                           |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Documentation  | [Coralogix Real User Monitoring](https://coralogix.com/docs/user-guides/rum/getting-started/real-user-monitoring/index.md) [Coralogix SDK for Browsers](https://www.npmjs.com/package/@coralogix/browser) |
| External Links | [Coralogix RUM CLI Library](https://www.npmjs.com/package/@coralogix/rum-cli)                                                                                                                             |

## Support

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email at [support@coralogix.com](mailto:support@coralogix.com).
