How to properly send Additional Data

Hi there!

I’m trying to use Additional Data in order to further debug an issue.

According to the documentation, I can do this and it should add additional data to each issue once it’s in the codebase.

Sentry.configureScope(function(scope) {
  scope.setExtra("character_name", "Mighty Fighter")
})

In my case, I’m doing this inside a submit method in a React app, so my code looks something like this…

handleSubmit (e) {
  e.preventDefault()
  try {
     // Code to try
  } catch (error) {
    Sentry.configureScope(function (scope) {
      scope.setExtra('error_location', 'email verification handleSubmit')
      scope.setExtra('component_state', this.state)
      scope.setExtra('component_props', this.props)
      Sentry.captureException(error)
    })
  }
}

However, when I look at my latest issue where an error occurs in this piece of code, no additional data shows up.

The only difference in my code is that I’m calling captureException after setting the additional data. Is this incorrect? If so, please advise what I should do in order to ensure the additional data gets displayed on the issue.

Really appreciate any help on this. Thank you.

Following up on this a bit, it looks like I needed to use a local scope by using Sentry.withScope rather than Sentry.configureScope. Based on this documentation
https://docs.sentry.io/enriching-error-data/scopes/?platform=javascript#local-scopes However, that still isn’t giving me the additional data I’m expecting.

Does the above code (when changing configureScope to withScope) look like it should work, or am I doing something wrong?

Thank you