Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raven-js not working with create-react-app #844

Closed
rbndg opened this issue Feb 1, 2017 · 13 comments
Closed

Raven-js not working with create-react-app #844

rbndg opened this issue Feb 1, 2017 · 13 comments
Assignees

Comments

@rbndg
Copy link

rbndg commented Feb 1, 2017

Hello, I built an app using create-react-app (https://github.com/facebookincubator/create-react-app), however Raven-js isn't able to pick up errors.
I'm however able to log errors with Raven.captureException.

I'm using the latest version of sentry and i followed the instructions on the Sentry website.

@benvinegar
Copy link
Contributor

Hey @rbndg – could you clone your repo and put it up on GitHub so I can inspect what's going on?

@benvinegar
Copy link
Contributor

ping

Any news here – can you provide me with an example repro?

@Yabes
Copy link

Yabes commented Apr 25, 2017

Same problem here, Raven doesn't send anything. I didn't try to log errors with Raven.captureException.

My code is fairly simple:

App.js

import Raven from 'raven-js';
Raven.config('<my-sentry-url>').install();

However, when I copy/paste the Raven-js code in my console, it catches and sends errors.

@HazAT HazAT self-assigned this May 10, 2017
@benvinegar
Copy link
Contributor

I need a full repro. I've been using create-react-app internally to demo Sentry and it's worked fine for the past few months.

@fcoury
Copy link

fcoury commented Dec 7, 2017

Did anyone solve this issue after it being closed? I am having this exact same issue.

@kamilogorek
Copy link
Contributor

What's exactly the issue? Can you provide your config/repro case? Without it, I cannot tell much.

@joshmreesjones
Copy link

I'm also having this issue.

@kamilogorek
Copy link
Contributor

@joshmreesjones what's the issue exactly? What's your setup? Your config? Can you provide reproducible repository? It's very hard to debug without knowing any of those things :)

@jamesmanning
Copy link

@benvinegar what's the Right Way to add raven to an app that's been created with create-react-app? Because of the need to load before bundles, I'm kind of assuming the public/index.html is the right place, but knowing how you're doing it successfully would be great!

@benvinegar
Copy link
Contributor

I'm kind of assuming the public/index.html is the right place, but knowing how you're doing it successfully would be great!

That's what I've done. I add a <script> link to the public CDN build of Raven.js, and also add a <script> with the .config() and .install() calls below.

@jamesmanning
Copy link

@benvinegar perfect, thanks! Does it Just Work even with react 16 or would someone need to add specific support for the error boundaries?

@kamilogorek
Copy link
Contributor

Hey @jamesmanning, it'll work just fine out of the box. You can read how to use error boundaries here though - https://blog.sentry.io/2017/09/28/react-16-error-boundaries

One thing to keep in mind is that React does bubble all the errors in development mode, even those caught by error boundaries (here's more context you can read about #1249 (comment))

@yann-yinn
Copy link

yann-yinn commented Jun 22, 2018

edit : This is a way to include raven only in production mode :)
In your index.html :

  <% if (process.env.NODE_ENV == 'production') { %>
    <script src="https://cdn.ravenjs.com/3.26.2/raven.min.js" crossorigin="anonymous"></script>
    <script>Raven.config('https://ba44729431a044d6915d8012e94d8a56@sentry.io/1230983', {
        environment: "%NODE_ENV%",
      }).install();
    </script>
    <% } %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants