question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raven.captureException() not capturing metadata

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

With this code:

Raven.config(sentryUrl, {tags: {test0: 'test'}}).install();

  Raven.setUserContext({
           test1: 'test',
        });
        Raven.setTagsContext({ test2:'test' });
        Raven.setExtraContext({  test3:'test' });
        Raven.captureException(err.reason, { logger: 'my.module', extra: 'extra', tags: { test4:'test' } });
 Raven.captureMessage(err.reason, { level: 'warning', extra: 'extra', tags: { test5:'test' } });

A warning and an error are logged. The warning has all the specified meta data, the error only test0.

What is the expected behavior?

That captureException captures the same metadata, the same way as captureMessage.

Which versions of Raven.js, and which browser and OS are affected by this issue? Are you using the CDN (http://ravenjs.com)?

I used both raven-js version 3.23.1 with webpack and <script src="https://cdn.ravenjs.com/3.23.1/raven.min.js" crossorigin="anonymous"></script>

Tested on Chrome Version 64.0.3282.186 on Windows 10

Did this work in previous versions of Raven.js? Don’t know, first time user.

Are you using hosted Sentry or on-premises? If on-premises, which version (e.g. 8.7.0)? Using https://sentry.io (paid account)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilogorekcommented, Mar 12, 2018

@wwwouter two things. Make sure that your actual ErrorBoundry is catching what it should (eg. don’t trigger error from the same component that implements it - it won’t work).

However, more important is that React does bubble all the errors in development mode and this is what happens in your case.

The first event, that doesn’t have tags is triggered using global error handler and only second one is yours. It took me a while to debug as it’s not obvious, but this is how React works. It doesn’t happen in production.

const BadComponent = () => {
  throw new Error("BadComponent");
};

class ErrorBoundary extends React.Component {
  componentDidCatch(error) {
    Raven.captureException(error, {
      tags: {
        something: "awesome"
      }   
    }); 
    Raven.captureException(new Error("foo"), {
      tags: {
        something: "awesome"
      }   
    }); 
  }

  render() {
    return this.props.children;
  }
}

ReactDOM.render(
  <ErrorBoundary>
    <BadComponent />
  </ErrorBoundary>,
  document.getElementById("main")
);

Here are two screenshots of the output

Development

screen shot 2018-03-12 at 16 07 38

Production

screen shot 2018-03-12 at 16 06 59

Hope it helps.

1reaction
wwwoutercommented, Mar 15, 2018

🥇 Thanks for the detailed explanation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage | Sentry Documentation
Capturing Errors You can use captureException to manually report errors: The recommended usage pattern, though, is to run your entire program inside a...
Read more >
Developers - Raven.captureException() not capturing metadata -
Raven.captureException() not capturing metadata · Do you want to request a feature or report a bug? Bug · What is the current behavior?...
Read more >
API Reference — Raven 5.32.0 documentation
This is a shorthand to reporting a message via capture() . It passes 'raven.events.Message' as event_type and the message along. All other keyword...
Read more >
How to use the raven.captureException function in raven - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... await new Promise((resolve, reject) =>...
Read more >
Tracking errors in Sentry (in node.js) - DEV Community ‍ ‍
Throw error } } Raven.context(function() { // Wrap the following code with ... With Raven's caputreException , you can capture non-thrown ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found