> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sourcemaps

Sourcemaps are a way to convert backtraces from minified or transpiled JavaScript files to their original representation in your source code. A sourcemap contains data about your front-end source code, which we can use to derive the function name, line and column number, and surrounding source code from the position referenced in the backtrace.

## Requirements

Enhancing backtraces with sourcemaps requires each sample to be tagged with a `revision` of your application. This is used to determine when to fetch new sourcemaps after a deploy has changed your (front-end) code. You can specify the revision in the options given when creating a new AppSignal instance.

<CodeGroup>
  ```js JavaScript theme={null}
  const appsignal = new Appsignal({
    key: "<your frontend API key>",
    revision: "<your current revision>",
  });
  ```
</CodeGroup>

## Public sourcemaps

With public sourcemaps, the sourcemap is hosted next to the JavaScript file. At the bottom of the minified JavaScript there needs to be a special comment to indicate that a sourcemap is available for the code.

<CodeGroup>
  ```js JavaScript theme={null}
  //# sourceMappingURL=file.js.map
  ```
</CodeGroup>

The URL in this comment can be a full URL to the sourcemap, or a relative path from the JavaScript file to the sourcemap.

For example, if the minified JS is hosted on: `https://your.app/assets/application.min.js` and the sourcemap comment looks like `//# sourceMappingURL=application.min.js.map`, we will attempt to retrieve the source map from the following URL: `https://your.app/assets/application.min.js.map`.

We attempt to cache public sourcemaps, but we may nonetheless request the minified version and the sourcemap file more than once.

## Private sourcemaps

We usually recommend using public sourcemaps whenever possible, as builds that produce lots of sourcemaps can take a long time to upload via our private sourcemap endpoint.

However, if that is not possible, you can also upload your sourcemaps to our [sourcemaps API endpoint](/api/sourcemaps).

### Retention

Sourcemaps are grouped into a "release" by the `revision` string and we will keep the last "release" until a new `revision` is uploaded. Older "releases" will be kept for up to sixty days.
