Code Monkey home page Code Monkey logo

honeybadger-io / honeybadger-react Goto Github PK

View Code? Open in Web Editor NEW
14.0 7.0 7.0 6.63 MB

Official React integration for Honeybadger.io :zap:

Home Page: https://www.honeybadger.io/for/javascript/?utm_source=github&utm_medium=readme&utm_campaign=react&utm_content=website-url

License: MIT License

HTML 14.03% JavaScript 14.91% CSS 2.98% Shell 3.78% TypeScript 64.29%
honeybadger react errors exceptions error-handling error error-monitoring error-handler crash-reporting crash

honeybadger-react's Introduction

Honeybadger React.js Integration

Build Status npm version

Note: This repository has been moved to @honeybadger-io/js, home to all Honeybadger's JavaScript packages.

React.js integration for Honeybadger.io

Documentation and Support

For comprehensive documentation and support, check out our documentation site.

The documentation includes a detailed React integration guide

Project Goals

The goal is to provide an idiomatic, simple integration of Honeybadger's exception monitoring service with React.js applications.

Project Status

This version is considered suitable for preview.

Limitations

Honeybadger-react hooks in to the error handler in React. This means we only notify Honeybadger of React context for errors that React handles. Some errors inside React code may propagate to the window onerror handler instead.

In those cases, Honeybadger Javascript library's default error notifier is invoked, which will contain a stack trace but none of the React variables.

Key Assumptions

This project is built using create-react-library with rollup and generates artifacts in commonjs, esm and umd formats. It's possible your own build environment may be just different enough to require some adjustments. If you find that our artifacts don't quite meet your needs, please file an issue on GitHub.

Example app

There's a minimal implementation of a honeybadger-react integration in the ./example folder. If you want to contribute a patch to honeybadger-react, it can be useful to have the demo app running.

To run it, issue these commands from your shell:

cd example
npm install
REACT_APP_HONEYBADGER_API_KEY=b425b636 npm run start

This will serve the demo app with hot reload at localhost:3000

For a detailed explanation on how hot reloading works, check out the documentation.

Changelog

See https://github.com/honeybadger-io/honeybadger-react/blob/master/CHANGELOG.md Changelog is automatically generated with our release automation process.

Contributing

  1. Fork it.
  2. Create a topic branch git checkout -b my_branch
  3. Commit your changes git commit -am "Boom"
  4. Push to your branch git push origin my_branch
  5. Send a pull request

Development

# install dependencies
npm install

# build for production
npm run build

# run unit tests
npm test

# automatically continuously rebuild the dist/ artifacts with hot reload when developing
npm run start

Releasing

  1. With a clean working tree, use npm version [new version] to bump the version, commit the changes, tag the release, and push to GitHub. See npm help version for documentation.
  2. To publish the release, use npm publish. See npm help publish for documentation.

Release Automation

We use Ship.js to automate releasing.

Ship.js creates a PR once per week when unreleased changes are present. You can also trigger a release PR by saying "@shipjs prepare" in any issue or pull request comment on GitHub.

Troubleshooting a failed Ship.js release

If a ship.js release fails, you need to revert the release commit and delete the release branch (e.g releases/v1.1.0) Then, you can debug the issue by simulating the release process locally (npm run release -- --dry-run --yes --no-browse).

License

honeybadger-react is MIT licensed. See the LICENSE file in this repository for details.

honeybadger-react's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

honeybadger-react's Issues

Transform to Typescript

Let's transform our honeybadger-react code into typescript.
As a bonus, we won't have to manually maintain typescript definitions.

Double notification in example React app

What are the steps to reproduce this issue?

  1. Clone repo
  2. `cd example/
  3. REACT_APP_HONEYBADGER_API_KEY=yourkey yarn start
  4. Visit http://localhost:3000/
  5. Click "Click here to trigger an error"

What happens?

Two error notifications are sent:

image

What were you expecting to happen?

Only one should be sent.

What versions are you using?

Operating System: Linux
Package Version: master
Browser: Firefox Developer Edition

Integrating our projects?

Hi there! I run the unofficial React integration for Honeybadger. I am super excited to see this as an official project! I'd love to discuss deprecating my project and integrating it into this one. Let me know if there is a good process for doing that that you would like to follow!

New release?

Will there be a new release of this package any time soon? There are fixes in master that have been hanging around since September…

Outdated version of @honeybadger-io/js 3.2.8 => 4.0.2

updating both @honeybadger-io/js and @honeybadger-io/react to latest version produces dependency conflict in yarn.lock

"@honeybadger-io/[email protected]", "@honeybadger-io/js@^3.2.8":
  version "4.0.2"
  resolved "https://registry.yarnpkg.com/@honeybadger-io/js/-/js-4.0.2.tgz#80c40eeb06f7379f43e36926a8490cfb5bc89096"
  integrity sha512-kK8UMc/2uA5WPFsn+Tj2ZTcwlVtctjPTogXk8QGCNirTKQV+5TGMm+dhpHP8R2Nj47oEQI3B/gnU9+U/gFEqzw==
  dependencies:
    stacktrace-parser "^0.1.10"

"@honeybadger-io/[email protected]":
  version "2.0.1"
  resolved "https://registry.yarnpkg.com/@honeybadger-io/react/-/react-2.0.1.tgz#50651ebd93fbb0daa2688d14d934301348cf62e8"
  integrity sha512-7Sr0ExI+s4CDYXPuZf9nUoy6KUofzyrwH09ZcjUVELySGrSpaBEDJplGzZ3tIdaV/oYkltWfyRaC+rnghsiH6g==
  dependencies:
    "@honeybadger-io/js" "^3.2.8"

ErrorComponent prop on HoneyBadgerErrorBoundary wasn't mentioned anywhere in docs

What are the steps to reproduce this issue?

  1. Apply at index
  2. Introduce some error on code

What happens?

the web page content on which the error is thrown is filled with the DefaultErrorComponent. What is not described on docs is that we can pass an error component to the <ErrorBoundary />

Any other comments?

I'd like to submit a PR containing the info about it

What versions are you using?

Package Version: 0.0.2

Fix documentation site

What are the steps to reproduce this issue?

  1. Set up honeybadger-react using code suggested for main.js on the honeybadger.io documentation site
  2. Observe "Unable to send error report: no API key has been configured" error in console

What happens?

API key is not set up correctly.

Any logs, error output, etc?

[Honeybadger] – "Unable to send error report: no API key has been configured"

Screenshot 2021-02-04 at 22 23 08

Any other comments?

Obviously nothing to change in this repository, but figured it would be the easiest way to alert y'all to the issue. It essentially comes down to this:

The documentation page suggests you set up const config with a key called api_key, but it should actually be set up with apiKey, as seen in this repositories example.

What versions are you using?

Operating System: macOS
Package Version: 1.0.0
Browser Version: Safari 13.0.2

Setup config and add context

Hey,

Like in your vue.js package it's good be more simple to only pass the config to the component.

What do you think?

Missing sourcemaps or a misconfigured package with Create React App - CRA

After updating to the newest version of Create React App I'm getting warnings for missing sourcemap files in this package. See below for the exact warnings, and see this issue for similar warnings.

What are the steps to reproduce this issue?

  1. Update any project using CRA to v5 and include the Honeybadger React library.
    1a. Here's an example repo if you need one to test with
  2. Start the dev server npm run start or build npm run build

What happens?

WARNING in ./node_modules/@honeybadger-io/react/dist/honeybadger-react.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<project>/node_modules/@honeybadger-io/src/DefaultErrorComponent.tsx' file: Error: ENOENT: no such file or directory, open '<project>/node_modules/@honeybadger-io/src/DefaultErrorComponent.tsx'

What were you expecting to happen?

No errors or warnings

What versions are you using?

Operating System: MacOS 10.15.7 / Node 16.3.0
Package Version: 2.0.0
Browser Version: N/A

react@18 support

While installing packages I see warning " > @honeybadger-io/[email protected]" has incorrect peer dependency "react@^15.0.0 || ^16.0.0 || ^17.0.0". in npm log

@honeybadger-io/react does not contain a default export as described in the docs

What are the steps to reproduce this issue?

  1. Install @honeybadger-io/react
  2. Import the ErrorBoundary component. Per the docs:
import ErrorBoundary from '@honeybadger-io/react'

What happens?

Produces an error:
Attempted import error: '@honeybadger-io/react' does not contain a default export (imported as 'ErrorBoundary').

What were you expecting to happen?

Any logs, error output, etc?

Attempted import error: '@honeybadger-io/react' does not contain a default export (imported as 'ErrorBoundary').
image

Any other comments?

This seems like just an issue of the docs being out of date. Can fix it like so:

import { HoneybadgerErrorBoundary as ErrorBoundary } from '@honeybadger-io/react';

What versions are you using?

Package Version: @honeybadger-io/react": "^2.0.0

Custom context values in error object discarded by react error handler

This bug report is based off of a customer support ticket. It causes error reporting to work differently in react vs window.onerror.

What are the steps to reproduce this issue?

  1. Have a honeybadger-react intsstallation
  2. Set custom context on an error object
  3. Throw error

Here's a paraphrasing of the customer's code:

const error = Error('Something happened');
error.context = {foo: 'bar'};
throw error;

What happens?

The custom context isn't included when the error is reported from componentDidCatch

This is because componentDidCatch passes in a different context object which clobbers error.context. https://github.com/honeybadger-io/honeybadger-js/blob/master/src/builder.js#L266

Meanwhile, if the same error is picked up by window.onError the context will be reported just fine.

What were you expecting to happen?

The custom context values to be included along with any react-specific context.

Any logs, error output, etc?

nope

Any other comments?

I've never seen people setting context directly on the JS Error object but it seems to work fine when not using honeybadger-react.

What versions are you using?

Package Version: master

TypeScript types are not included in npm package

What are the steps to reproduce this issue?

  1. npm install @honeybadger-io/react
  2. cd node_modules/@honeybadger-io/react/
  3. cat package.json | grep "d.ts" => "types": "./honeybadger-react.d.ts",. Types are listed, so I know I am using a version that knows about types in the package.
  4. ls honeybadger-react.d.ts => nothing. types are not included.

What happens?

The types are not delivered with the module.

What were you expecting to happen?

Types!

Any other comments?

wget https://raw.githubusercontent.com/honeybadger-io/honeybadger-react/master/honeybadger-react.d.ts solves the problem, so the file is simply being omitted from the module.

What versions are you using?

Operating System: Mac OS X
Package Version: 0.0.5
Browser Version: N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.