├── .gitignore
├── LICENSE
├── README.md
├── gatsby-browser.js
├── index.js
├── package-lock.json
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Jason Stallings
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gatsby-plugin-sentry
2 |
3 | Gatsby plugin to add Sentry error tracking to your site.
4 |
5 | Learn more about Sentry [here](https://sentry.io).
6 |
7 | ## Install
8 |
9 | `npm install --save gatsby-plugin-sentry`
10 |
11 | ## How to use
12 |
13 | ```javascript
14 | // In your gatsby-config.js
15 | plugins: [
16 | {
17 | resolve: "gatsby-plugin-sentry",
18 | options: {
19 | dsn: "YOUR_SENTRY_DSN_URL",
20 | // Optional settings, see https://docs.sentry.io/clients/node/config/#optional-settings
21 | environment: process.env.NODE_ENV,
22 | enabled: (() => ["production", "stage"].indexOf(process.env.NODE_ENV) !== -1)()
23 | }
24 | }
25 | ];
26 | ```
27 |
28 | Now `Sentry` is available in global window object. so you can use it in `react 16` like:
29 |
30 | ```javascript
31 | export default class ErrorBoundary extends React.Component {
32 |
33 | constructor(props) {
34 | super(props);
35 | this.state = { error: null };
36 | }
37 |
38 | componentDidCatch(error, errorInfo) {
39 | this.setState({ error });
40 | Sentry.configureScope((scope) => {
41 | Object.keys(errorInfo).forEach(key => {
42 | scope.setExtra(key, errorInfo[key]);
43 | });
44 | });
45 | Sentry.captureException(error);
46 | }
47 |
48 | render() {
49 | if (this.state.error) {
50 | // render fallback UI
51 | return
Something went wrong!
;
52 | } else {
53 | // when there's not an error, render children untouched
54 | return this.props.children;
55 | }
56 | }
57 | }
58 | ```
59 |
--------------------------------------------------------------------------------
/gatsby-browser.js:
--------------------------------------------------------------------------------
1 | exports.onClientEntry = function(_, pluginParams) {
2 | require.ensure(['@sentry/browser'], function(require) {
3 | const Sentry = require('@sentry/browser');
4 | Sentry.init(pluginParams);
5 | window.Sentry = Sentry;
6 | });
7 | };
8 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | // noop
2 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gatsby-plugin-sentry",
3 | "version": "1.0.1",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@sentry/browser": {
8 | "version": "4.1.1",
9 | "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-4.1.1.tgz",
10 | "integrity": "sha512-rmkGlTh0AL3Jf0DvF3BluChIyzPkkYpNgIwEHjxTUiLp6BQdgwakZuzBqSPJrEs+jMsKMoesOuJ/fAAG0K7+Ew==",
11 | "requires": {
12 | "@sentry/core": "4.1.1",
13 | "@sentry/types": "4.1.0",
14 | "@sentry/utils": "4.1.1"
15 | }
16 | },
17 | "@sentry/core": {
18 | "version": "4.1.1",
19 | "resolved": "https://registry.npmjs.org/@sentry/core/-/core-4.1.1.tgz",
20 | "integrity": "sha512-QJExTxZ1ZA5P/To5gOwd3sowukXW0N/Q9nfu8biRDNa+YURn6ElLjO0fD6eIBqX1f3npo/kTiWZwFBc7LXEzSg==",
21 | "requires": {
22 | "@sentry/hub": "4.1.1",
23 | "@sentry/minimal": "4.1.1",
24 | "@sentry/types": "4.1.0",
25 | "@sentry/utils": "4.1.1"
26 | }
27 | },
28 | "@sentry/hub": {
29 | "version": "4.1.1",
30 | "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-4.1.1.tgz",
31 | "integrity": "sha512-VmcZOgcbFjJzK1oQNwcFP/wgfoWQr24dFv1C0uwdXldNXx3mwyUVkomvklBHz90HwiahsI/gCc+ZmbC3ECQk2Q==",
32 | "requires": {
33 | "@sentry/types": "4.1.0",
34 | "@sentry/utils": "4.1.1"
35 | }
36 | },
37 | "@sentry/minimal": {
38 | "version": "4.1.1",
39 | "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-4.1.1.tgz",
40 | "integrity": "sha512-xRKWA46OGnZinJyTljDUel53emPP9mb/XNi/kF6SBaVDOUXl7HAB8kP7Bn7eLBwOanxN8PbYoAzh/lIQXWTmDg==",
41 | "requires": {
42 | "@sentry/hub": "4.1.1",
43 | "@sentry/types": "4.1.0"
44 | }
45 | },
46 | "@sentry/types": {
47 | "version": "4.1.0",
48 | "resolved": "https://registry.npmjs.org/@sentry/types/-/types-4.1.0.tgz",
49 | "integrity": "sha512-KY7B9wYs1NACHlYzG4OuP6k4uQJkyDPJppftjj3NJYShfwdDTO1I2Swkhhb5dJMEMMMpBJGxXmiqZ2mX5ErISQ=="
50 | },
51 | "@sentry/utils": {
52 | "version": "4.1.1",
53 | "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-4.1.1.tgz",
54 | "integrity": "sha512-XMvGqAWATBrRkOF0lkt0Ij8of2mRmp4WeFTUAgiKzCekxfUBLBaTb4wTaFXz1cnnnjVTwcAq72qBRMhHwQ0IIg==",
55 | "requires": {
56 | "@sentry/types": "4.1.0"
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gatsby-plugin-sentry",
3 | "description": "Gatsby plugin to add Sentry error tracking to your site.",
4 | "version": "1.0.1",
5 | "author": "Jason Stallings ",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/octalmage/gatsby-plugin-sentry.git"
9 | },
10 | "keywords": [
11 | "gatsby",
12 | "gatsby-plugin",
13 | "sentry"
14 | ],
15 | "license": "MIT",
16 | "main": "index.js",
17 | "dependencies": {
18 | "@sentry/browser": "latest"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------