# bugsnag-sourcemaps

> [![Latest version](https://img.shields.io/npm/v/bugsnag-sourcemaps.svg)](https://www.npmjs.com/package/bugsnag-sourcemaps) [![Next version](https://img.shields.io/npm/v/bugsnag-sourcemaps/next.svg)](https://www.npmjs.com/package/bugsnag-sourcemaps) [![Dep

Latest version **1.3.0** (published 2020-04-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bugsnag-sourcemaps
pnpm add bugsnag-sourcemaps
yarn add bugsnag-sourcemaps
bun add bugsnag-sourcemaps
```

Provides the command `bugsnag-sourcemaps`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2020-04-01 |
| First published | 2017-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 33 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Jacob Marshall |
| Maintainers | bengourley, jacobmarshall, jamie-bugsnag, kattrali |
| Keywords | bugsnag, source-maps |

## Links

- npm: https://www.npmjs.com/package/bugsnag-sourcemaps
- Repository: https://github.com/bugsnag/bugsnag-sourcemaps
- Issues: https://github.com/bugsnag/bugsnag-sourcemaps/issues
- npm.io page: https://npm.io/package/bugsnag-sourcemaps

## Dependencies (10)

- [rc](https://npm.io/package/rc.md) ^1.2.8
- [glob](https://npm.io/package/glob.md) ^7.1.4
- [meow](https://npm.io/package/meow.md) ^3.7.0
- [once](https://npm.io/package/once.md) ^1.4.0
- [kleur](https://npm.io/package/kleur.md) ^3.0.3
- [form-data](https://npm.io/package/form-data.md) ^2.3.3
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.11
- [read-pkg-up](https://npm.io/package/read-pkg-up.md) ^2.0.0
- [concat-stream](https://npm.io/package/concat-stream.md) ^2.0.0
- [run-parallel-limit](https://npm.io/package/run-parallel-limit.md) ^1.0.5

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2020-04-01
- 1.0.0-rc.6 (next) — 2017-07-13
- 1.2.2 — 2019-11-01
- 1.2.1 — 2019-05-23
- 1.2.0 — 2019-05-22
- 1.1.0 — 2019-01-21
- 1.0.7 — 2018-12-19
- 1.0.6 — 2018-12-14
- 1.0.5 — 2018-12-04
- 1.0.4 — 2018-08-01
- 1.0.3 — 2018-02-20
- 1.0.2 — 2018-02-15
- 1.0.1 — 2017-08-10
- 1.0.0 — 2017-08-04
- 1.0.0-rc.5 — 2017-07-06
- … 7 more at https://npm.io/package/bugsnag-sourcemaps/versions

## README

# bugsnag-sourcemaps

[![Latest version](https://img.shields.io/npm/v/bugsnag-sourcemaps.svg)](https://www.npmjs.com/package/bugsnag-sourcemaps)
[![Next version](https://img.shields.io/npm/v/bugsnag-sourcemaps/next.svg)](https://www.npmjs.com/package/bugsnag-sourcemaps)
[![Dependencies](https://david-dm.org/bugsnag/bugsnag-sourcemaps.svg)](https://david-dm.org/bugsnag/bugsnag-sourcemaps)
[![Monthly downloads](https://img.shields.io/npm/dm/bugsnag-sourcemaps.svg)](https://www.npmjs.com/package/bugsnag-sourcemaps)
[![Build status](https://travis-ci.org/bugsnag/bugsnag-sourcemaps.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-sourcemaps)
[![Build status](https://ci.appveyor.com/api/projects/status/lfm5kxi7ew6i1780?svg=true)](https://ci.appveyor.com/project/jmshal/bugsnag-sourcemaps)

A Node.js module to programmatically upload your sourcemap files to Bugsnag.

## Installation

```sh
$ npm install --global bugsnag-sourcemaps
```

## Command-line Usage

`bugsnag-sourcemaps` provides a command-line interface for uploading source maps
directly. Run `bugsnag-sourcemaps --help` for a list of all options.

For a typical browser bundle, where your build generates a single minified file and accompanying source map:

```shell
$ bugsnag-sourcemaps upload --api-key YOUR_API_KEY_HERE \
    --app-version 1.2.3 \
    --minified-url 'http://example.com/assets/example.min.js' \
    --source-map path/to/example.js.map \
    --minified-file path/to/example.min.js \
    --overwrite \
    --upload-sources
```

For a typical Node.js project, where your build generates a source map per input file (e.g. Babel, TypeScript):

```shell
$ bugsnag-sourcemaps upload --api-key YOUR_API_KEY_HERE \
    --app-version 1.2.3 \
    --directory
```

### Options

```
-h, --help                 Prints this message
-k, --api-key KEY          Your project API key
-v, --app-version VERSION  The version number of your app
-c, --code-bundle-id ID    The code bundle id (react-native only)
-d, --directory [PATH]     Enable directory mode. Searches for multiple source
                           maps in the directory and uploads them all. Only
                           supply a path if the directory you want to search is
                           not the same as your project root.
                           This option makes the following options redundant:
                             --source-map
                             --minified-url
                             --minified-file
-e, --endpoint URL         The URL of the upload server
-m, --minified-url URL     The URL your users will request your bundle
-s, --source-map PATH      The path of the source map file (local)
-p, --minified-file PATH   The path of the bundle (local)
-u, --upload-sources       Upload source files referenced by the source map
-n, --upload-node-modules  Upload dependency files referenced by the source map
-r, --project-root PATH    The root path to remove from absolute file paths
-w, --add-wildcard-prefix  Insert a wildcard prefix when stripping root path
-o, --overwrite            Overwrite previously uploaded source maps
```

## API Usage

```js
import path from 'path';
import { upload } from 'bugsnag-sourcemaps';

upload({
  agent, // optional (node http agent)
  apiKey: 'YOUR_API_KEY_HERE',
  appVersion: '1.2.3', // optional
  codeBundleId: '1.0-123', // optional (react-native only)
  minifiedUrl: 'http://example.com/assets/example.min.js', // supports wildcards
  sourceMap: path.resolve(__dirname, 'path/to/example.js.map'),
  minifiedFile: path.resolve(__dirname, 'path/to/example.min.js'), // optional
  overwrite: true, // optional
  sources: {
    'http://example.com/assets/main.js': path.resolve(__dirname, 'path/to/main.js'),
    'http://example.com/assets/utils.js': path.resolve(__dirname, 'path/to/utils.js'),
  },
}, function(err) {
  if (err) {
    throw new Error('Something went wrong! ' + err.message);
  }
  console.log('Sourcemap was uploaded successfully.');
});
```

### Bugsnag On-premise

If you are using Bugsnag On-premise, you should use the `endpoint` option to set the url of your upload server.

Example with endpoint option:

```js
import path from 'path';
import { upload } from 'bugsnag-sourcemaps';

upload({
  // apiKey, appVersion, etc...
  endpoint: 'https://bugsnag.my-company.com',
}, function(err) {
  // ...
});
```

## License

MIT License ❤️

---
_Source: https://npm.io/package/bugsnag-sourcemaps · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
