---
title: "How to upload source maps to Honeybadger"
description:
  "The BigBinary team's lesson on how to upload source maps to Honeybadger."
canonical_url: "https://www.bigbinary.com/blog/how-to-upload-source-maps-to-honeybadger"
markdown_url: "https://www.bigbinary.com/blog/how-to-upload-source-maps-to-honeybadger.md"
---

# How to upload source maps to Honeybadger

The BigBinary team's lesson on how to upload source maps to Honeybadger.

- Author: Arbaaz
- Published: July 16, 2018
- Categories: JavaScript

During the development of a chrome extension, debugging was difficult because
line number of minified JavaScript file is of no use without a source map.
Previously, Honeybadger could only download the source map files which were
public and our source maps were inside the `.crx` package which was inaccessible
to honeybadger.

Recently, Honeybadger released a new
[feature](http://blog.honeybadger.io/source-map-upload/) to upload the source
maps to Honeybadger. We have written a grunt plugin to upload the source maps to
Honeybadger.

Here is how we can upload source map to Honeybadger.

First, install the grunt plugin.

```bash
npm install --save-dev grunt-honeybadger-sourcemaps
```

Configure the gruntfile.

```javascript
grunt.initConfig({
  honeybadger_sourcemaps: {
    default_options:{
      options: {
        appId: "xxxx",
        token: "xxxxxxxxxxxxxx",
        urlPrefix: "http://example.com/",
        revision: "<app version>"
        prepareUrlParam: function(fileSrc){
          // Here we can manipulate the filePath
          return filesrc.replace('built/', '');
        },
      },
      files: [{
        src: ['@path/to/**/*.map']
      }],
    }
  },
});
grunt.loadNpmTasks('grunt-honeybadger-sourcemaps');
grunt.registerTask('upload_sourcemaps', ['honeybadger_sourcemaps']);
```

```plaintext

We can get the `appId` and `token` from Honeybadger project settings.


~~~plaintext
grunt upload_sourcemaps
```

Now, we can upload the source maps to Honeybadger and get better error stack
trace.

## Testing

Clone the following repo.

```bash
git clone https://github.com/bigbinary/grunt-honeybadger-sourcemaps
```

Replace `appId` and `token` in Gruntfile.js and run `grunt test`. It should
upload the sample source maps to your project.

## Links

- [Human page](https://www.bigbinary.com/blog/how-to-upload-source-maps-to-honeybadger)
