Logo of AppSignal

Menu
Documentation navigation

Sourcemaps beta

Warning: Beta implementation.

This is a Beta implementation, which means:

  • We do our best to process every front-end backtrace and enrich them with sourcemap data.
  • Specific scenario's might fail, but we'll try and fix those.

Sourcemaps are a way to convert (minified) JavaScript backtraces such as https://your.host/application-minified.js:53:9895 to something a bit more helpful. A sourcemap contains data about your front-end source code and given the minified file, line number and column number, we can ask a sourcemap for the original function, line/column number and even surrounding source code.

Table of Contents

Requirements

Enhancing backtraces with sourcemaps has one requirement:

  • Each sample needs to 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.
1
2
3
4
const appsignal = new Appsignal({
  key: "<your frontend API key>",
  revision: "<your current revision>"
})

Public sourcemaps

With public sourcemaps the sourcemap is hosted next to the (minified) 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.

1
//# sourceMappingURL=file.js.map

The URL in this comment can either be a full URL or a relative path to the sourcemap. If the URL is relative, we use the file path of the minified source to determine a full URL.

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

Our system has limited caching of public sourcemaps, this means that we can request the minified version and the sourcemap file multiple times after a deploy.

Private sourcemaps

When you don't want to make your sourcemap public, you can upload them to our sourcemaps API endpoint.

Sending sourcemaps

A CURL command would look like this:

1
2
3
4
5
curl -k -X POST -H 'Content-Type: multipart/form-data' \
  -F 'name[]=https://test.local/main.abc123.js' \
  -F 'revision=abcdef' \
  -F 'file=@/~project/main.js.map' \
  'https://appsignal.com/api/sourcemaps?push_api_key=xxx&app_name=AppSignal&environment=development'

We match the name[] fields against the full backtrace url e.g. the following backtrace line:

1
 at https://test.local/main.abc123.js:1:92623\"

Will match with the name: https://test.local/main.abc123.js. You can add multiple name's in one curl request:

1
2
3
4
5
6
curl -k -X POST -H 'Content-Type: multipart/form-data' \
  -F 'name[]=https://test.local/main.abc123.js' \
  -F 'name[]=https://cdn.local/main.abc123.js' \
  -F 'revision=abcdef' \
  -F 'file=@/~project/main.js.map' \
  'https://appsignal.com/api/sourcemaps?push_api_key=xxx&app_name=AppSignal&environment=development'

You can read more about the sourcemap API endpoint on the documentation page.

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.

We'd like to set cookies, read why.