Where to call Sentry.configureScope? Where to call Sentry.configureScope? reactjs reactjs

Where to call Sentry.configureScope?


I think you should use Sentry.withScope in your ErrorBoundary, this is what works in my app:

function logError(error, extraContext = {}) {  Sentry.withScope(scope => {    scope.setExtra('battery', 0.7);    scope.setTag('user_mode', 'admin');    scope.setUser({ 'id', '4711' });    if(extraContext.extra) {      Object.keys(extraContext.extra).forEach(key => {        scope.setExtra(key, extraContext.extra[key])      });    }    Sentry.captureException(error);  });

Reference : https://docs.sentry.io/enriching-error-data/scopes/?platform=javascript#local-scopes