> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/getting-started/installation-and-updating/connect-rum/source-maps.md). Agents can also search and read this documentation through its [MCP server](https://docs.groundcover.com/~gitbook/mcp).

# Source Maps

Upload source maps so browser and React Native stack traces show your original files, lines, and function names.

Source maps map minified or bundled JavaScript back to your original source files. With them, stack traces in RUM, in the session drawer and on the **Exceptions** page, show your real file names, line numbers, and function names instead of bundle names and minified positions.

| Stack trace                                                     | Supported                            |
| --------------------------------------------------------------- | ------------------------------------ |
| Browser JavaScript errors                                       | Yes, with the source maps you upload |
| React Native JavaScript errors                                  | Yes, with the source maps you upload |
| Native iOS (Swift), Android (Kotlin), and Flutter (Dart) frames | No                                   |

Native frames, including native crashes in React Native apps, appear in groundcover as they were reported, without symbolication.

## Find the source maps

### Browser

Turn on source map output in your production build, for example `build.sourcemap` in Vite or `devtool: 'source-map'` in webpack. Upload each `.map` file your bundler writes next to its bundle.

### React Native

| Build            | Bundle file in the stack frame | Upload the map as          |
| ---------------- | ------------------------------ | -------------------------- |
| Android (Hermes) | `index.android.bundle`         | `index.android.bundle.map` |
| iOS (Hermes)     | `main.jsbundle`                | `main.jsbundle.map`        |
| Expo             | `index-<hash>.hbc`             | `index-<hash>.hbc.map`     |

Upload the final source map of the release build. With Hermes, that's the composed map whose positions match the bytecode the device runs. Stack traces from development builds served by Metro aren't resolved.

* **Android:** a release build writes `android/app/build/generated/sourcemaps/react/release/index.android.bundle.map`.
* **iOS:** set `SOURCEMAP_FILE` in the **Bundle React Native code and images** build phase, for example `export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"`.
* **Expo:** `npx expo export --source-maps` writes each platform's bundle next to its map.

## Upload source maps

Upload each map from your CI job after the release build, before you ship the release. You need:

* **Your ingestion endpoint**, set below as `OTLP_HTTP_ENDPOINT`. It's your BYOC endpoint, shown on the [Ingestion Keys tab](https://app.groundcover.com/settings?selectedTab=ingestion-keys), and the same host you set as the SDK's `dsn`, for example `https://example.platform.grcv.io`. See [Ingestion endpoints](https://docs.groundcover.com/collect-data/byoc/ingestion-endpoints.md).
* **A RUM** [**ingestion key**](https://docs.groundcover.com/collect-data/ingestion-keys.md), set below as `INGESTION_TOKEN` and sent as a bearer token. It's the same key you set as `apiKey` in the SDK.

```bash
curl -fS \
  -X POST "${OTLP_HTTP_ENDPOINT}/rum/sourcemaps" \
  -H "Authorization: Bearer ${INGESTION_TOKEN}" \
  -F "app_id=${APP_ID}" \
  -F "release_id=${RELEASE_ID}" \
  -F "file=@${MAP_FILE}"
```

| Form field   | Value                                                                                                                                   |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| `app_id`     | The `appId` from the SDK's `init` call.                                                                                                 |
| `release_id` | The `releaseId` from the SDK's `init` call. On mobile, the app version when `releaseId` isn't set.                                      |
| `file`       | The source map's path, set above as `MAP_FILE`. Its file name must be the bundle's file name plus `.map`, such as `main.abc123.js.map`. |

Both IDs may contain letters, digits, hyphens, underscores, and dots, so reverse-DNS IDs such as `com.acme.shop` work. A dot can only sit between other characters: an ID that starts or ends with a dot, or has two dots in a row, uploads but never resolves.

{% hint style="warning" %}
The source map upload endpoints at `https://api.groundcover.com/api/rum/sourcemaps` and `https://app.groundcover.com/api/rum/sourcemaps` are deprecated. Upload to `${OTLP_HTTP_ENDPOINT}/rum/sourcemaps` with a RUM ingestion key instead.
{% endhint %}

A successful upload returns `201`:

```json
{
  "status": "uploaded",
  "app_id": "my-web-app",
  "release_id": "1.2.3",
  "filename": "main.js.map",
  "size_bytes": 524288
}
```

Stack traces are resolved when events arrive, so upload maps before you ship the release. Events that arrived before the upload stay unresolved, and a newly uploaded map can take a few minutes to be picked up.

### Retention

Maps are stored in your BYOC storage bucket at `sourcemaps/<app_id>/<release_id>/<filename>`, and kept until you delete them from the bucket. Each release's maps are stored under their own path, so uploading a new release doesn't remove older ones. Uploading a map with the same app ID, release, and file name replaces the previous one.

## How maps are matched

groundcover resolves a JavaScript stack frame when it finds an uploaded map that matches all three of these:

* **`app_id`**: the `appId` you pass to the SDK's `init` call.
* **`release_id`**: the `releaseId` you pass to the SDK's `init` call. When `releaseId` isn't set, groundcover uses the app version (`app.version`) as the release, which the mobile SDKs report automatically.
* **File name**: the file name in the stack frame, plus `.map`. For example, a frame in `main.abc123.js` resolves with a map uploaded as `main.abc123.js.map`.

Set `releaseId` in the SDK for every release you ship, and upload that release's maps with the same value. On mobile, if you leave `releaseId` unset, upload the maps under the app version instead.

## Check resolution

Each exception event records how its stack trace was resolved:

* `stacktrace_resolved_status`: `resolved`, `partial`, `unresolved`, or `none of the N frames could be resolved`.
* `stacktrace_resolving_error`: the reason when frames couldn't be resolved. The most common reasons are:
  * `map not found: <app>/<release>/<file>.map`: no map was uploaded under that app, release, and file name.
  * `missing app_id or release_id attributes`: the event had no app ID or no release. Set `appId`, and set `releaseId` or report an app version.
  * `position L:C not in map`: the map comes from a different build than the one that crashed.
  * `no resolver for <file>`: the frame isn't JavaScript, such as a native or Dart frame. These frames are never resolved.

To see how your stack traces resolve and why some don't, open [Explore](https://app.groundcover.com/explore/data-explorer), select **RUM**, switch the query to code mode, and run this query. For a React Native app, use `category:mobile-rum` instead of `category:rum` and add `-error_metadata.native:true` to leave out native crashes and hangs, which report `no resolver for <file>`.

```gcql
category:rum type:exception | stats by (stacktrace_resolved_status, stacktrace_resolving_error) count() as events | sort by (events desc) | limit 20
```

See [Querying RUM data](https://docs.groundcover.com/investigate/real-user-monitoring-rum/querying.md) for more queries.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groundcover.com/getting-started/installation-and-updating/connect-rum/source-maps.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
