javascriptloggingsentry

How do I test that Sentry is reporting errors?


I just installed Sentry for a client-side JavaScript app using the standard code snippet they provided. How do I test that it's working properly? I've tried manually throwing an error from my browser console and it didn't appear in Sentry. Is there any documentation on the right way to do this?


Solution

  • Verify (Browser)

    This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

    setTimeout(() => {
      throw new Error("Sentry Test Error");
    });
    

    <button> example

    <button type="button" onclick="throw new Error("Sentry Test Error")">Click Me!</button>
    

    Project Setup Wizard (React Native)

    <Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>
    

    Verify (old)

    myUndefinedFunction();
    

    Verifying Your Setup (older)

    Sentry.captureException(new Error("This is my fake error message"));
    

    Could be worth double-checking your setup (or updating) and config too.