Skip to content

Commit

Permalink
feat: migrate gatsby-plugin to monorepo (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
subzero10 authored Oct 4, 2022
1 parent dd3dbab commit 84bc0f9
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ You can refer to the README of each package for more information and instruction
- [@honeybadger-io/react](./packages/react)
[![npm version](https://badge.fury.io/js/%40honeybadger-io%2Freact.svg)](https://badge.fury.io/js/%40honeybadger-io%2Freact)
SDK for React integration
- [@honeybadger-io/gatsby-plugin-honeybadger](./packages/gatsby-plugin)
[![npm version](https://badge.fury.io/js/%40honeybadger-io%2Fgatsby-plugin-honeybadger.svg)](https://badge.fury.io/js/%40honeybadger-io%2Fgatsby-plugin-honeybadger)
[Gatsby](https://www.gatsbyjs.com) plugin

## Documentation and Support

Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
node_modules
yarn-error.log
Empty file.
22 changes: 22 additions & 0 deletions packages/gatsby-plugin/MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013, Honeybadger Industries LLC

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
44 changes: 44 additions & 0 deletions packages/gatsby-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# @honeybadger-io/gatsby-plugin-honeybadger

![Node CI](https://github.com/honeybadger-io/honeybadger-js/workflows/Node%20CI/badge.svg)
[![npm version](https://badge.fury.io/js/%40honeybadger-io%2Fgatsby-plugin-honeybadger.svg)](https://badge.fury.io/js/%40honeybadger-io%2Fgatsby-plugin-honeybadger)
[![npm dm](https://img.shields.io/npm/dm/@honeybadger-io/gatsby-plugin-honeybadger)](https://www.npmjs.com/package/@honeybadger-io/gatsby-plugin-honeybadger)
[![npm dt](https://img.shields.io/npm/dt/@honeybadger-io/gatsby-plugin-honeybadger)](https://www.npmjs.com/package/@honeybadger-io/gatsby-plugin-honeybadger)

Gatsby plugin to add [Honeybadger error tracking](https://www.honeybadger.io/for/javascript/?utm_source=github&utm_medium=readme&utm_campaign=gatsby&utm_content=Honeybadger+error+tracking) to your site.

## Install

`npm install --save @honeybadger-io/gatsby-plugin-honeybadger`

## How to use

Add your API key in the plugin options in `gatsby-config.js`:

```js
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `@honeybadger-io/gatsby-plugin-honeybadger`,
options: {
apiKey: 'YOUR_API_KEY',
revision: `${Date.now()}`,
assetsUrl: 'https://foobar.com/assets',
environment: process.env.NODE_ENV
}
}
]
}
```

### Options

- `[apiKey]` _(String)_: the API key of your Honeybadger project.
- `[revision]` _(String)_: `gatsby-plugin-honeybadger` uses [`honeybadger-webpack`](https://github.com/honeybadger-io/honeybadger-webpack) to upload source maps to Honeybadger. `options.revision` needs to be unique as it is the identifier that connects your errors to your source maps.
- `[assetsURL]` _(String)_: The base URL to production assets (scheme://host/path). Used to grab source maps.
- `[environment]` _(String)_: Current environment. Used to indicate the environment where the error occurred. **Optional**, defaults to `process.env.NODE_ENV`.

## License

This package is MIT licensed. See the [MIT-LICENSE](./MIT-LICENSE) file in this folder for details.
14 changes: 14 additions & 0 deletions packages/gatsby-plugin/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Honeybadger = require('honeybadger-js')

exports.onClientEntry = function(_, { apiKey, revision, environment = process.env.NODE_ENV }) {
if (!apiKey) {
console.warn('gatsby-plugin-honeybadger needs an API key to be configured properly {url for documentation}')
return
}

Honeybadger.configure({
apiKey,
revision,
environment
})
}
13 changes: 13 additions & 0 deletions packages/gatsby-plugin/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const HoneybadgerSourceMapPlugin = require('@honeybadger-io/webpack')

exports.onCreateWebpackConfig = ({ actions }, { apiKey, revision, assetsUrl }) => {
actions.setWebpackConfig({
plugins: [
new HoneybadgerSourceMapPlugin({
apiKey,
revision,
assetsUrl
})
]
})
}
1 change: 1 addition & 0 deletions packages/gatsby-plugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// noop
21 changes: 21 additions & 0 deletions packages/gatsby-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@honeybadger-io/gatsby-plugin-honeybadger",
"description": "Gatsby plugin to add Honeybadger error tracking to your site.",
"version": "0.1.3",
"homepage": "https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/gatsby-plugin",
"repository": {
"type": "git",
"url": "[email protected]:honeybadger-io/honeybadger-js.git"
},
"keywords": [
"gatsby",
"gatsby-plugin",
"honeybadger"
],
"license": "MIT",
"main": "index.js",
"dependencies": {
"@honeybadger-io/webpack": "^4.3.1",
"@honeybadger-io/js": "^4.3.1"
}
}

0 comments on commit 84bc0f9

Please sign in to comment.