Using our source map library you can upload source maps to unminify stack traces and get human-readable method names, files, and line numbers.
@bugsnag/source-maps
provides a CLI and a JavaScript library that can be used to upload your application’s source maps.
Install it globally on your system:
npm install --global @bugsnag/source-maps
# or
yarn global add @bugsnag/source-maps
Or locally inside your project:
npm install --save-dev @bugsnag/source-maps
# or
yarn add --dev @bugsnag/source-maps
The library can be used via the command line:
# CLI
bugsnag-source-maps upload-browser <opts>
Or as a JavaScript API:
// JS API
const { browser } = require('@bugsnag/source-maps')
interface browser {
async function uploadOne (UploadSingleOpts): Promise<void>
async function uploadMultiple (UploadMultipleOpts): Promise<void>
}
For a typical browser bundle, where your build generates a single minified file and accompanying source map:
bugsnag-source-maps upload-browser \
--api-key YOUR_API_KEY_HERE \
--app-version 1.2.3 \
--bundle-url http://yourdomain.url/assets/example.min.js \
--source-map path/to/example.js.map \
--bundle path/to/example.min.js
If your build generates multiple assets (such as a Create React App build), you can supply the directory and the baseURL path. For example, if your output goes into build/static/js
and that directory is served at http://yourdomain.url/static/js/*
:
bugsnag-source-maps upload-browser \
--api-key YOUR_API_KEY_HERE \
--app-version 1.2.3 \
--base-url http://yourdomain.url/static/js/ \
--directory build/static/js
The full set of options for @bugsnag/source-maps
.
Property (CLI, JS API) | Type | Description |
---|---|---|
--api-key , apiKey |
string |
your project’s API key [required] |
--app-version , appVersion |
string |
the version of the application you are building (this should match the appVersion configured in your notifier). |
--detect-app-version , detectAppVersion |
boolean |
detect the app version from the package.json file |
--endpoint , endpoint |
string |
customize the endpoint for BugSnag On-Premise |
--idle-timeout , idleTimeout |
number |
idle timeout for HTTP requests in minutes (see the Node request.setTimeout docs) |
logger (JS only) |
Object |
provide a custom logger (must match the internal Logger interface) |
--overwrite , overwrite |
boolean |
whether to replace existing source maps uploaded with the same version |
--project-root , projectRoot |
string |
the top level directory of your project |
requestOpts (JS only) |
RequestOptions |
supply options that should be passed to http.request() , for example if you need to provide an agent to send via a proxy. |
--quiet (CLI only) |
boolean |
less verbose logging |
Single upload options | ||
--source-map , sourceMap |
string |
the path to the source map [required] |
--bundle-url , bundleUrl |
string |
the URL the bundle is served at (may contain * wildcards) [required] |
--bundle , bundle |
string |
the path to the bundle |
Multiple upload options | ||
--directory , directory |
string |
the directory to start searching for source maps in, relative to the project root [required] |
--base-url , baseUrl |
string |
the base URL that JS bundles are served from (may contain * wildcards) [required] |