Skip to content

Propagation of beforeCapture or withErrorBoundary to parent #9091

Closed as not planned
@julianCast

Description

@julianCast

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/gatsby

SDK Version

7.67.0

Framework Version

@sentry/react

Steps to Reproduce

I have a root component that wraps other children, and I would like to be able to use both beforeCapture (child and parent) but I'm unable to propagate beforeCapture or any method within withErrorBoundary. Is there a way? Thank you.

export default Sentry.withErrorBoundary(RootElementWrapper, {
  beforeCapture: (scope, error) => {
     console.log("do something else", error);
     scope.setTag("error",error.mesage)
  },
});

and

export default Sentry.withErrorBoundary(PageElementWrapper, {
  beforeCapture: (scope, error) => {
    console.log("do something", error);
    scope.setTag("location","page")
  },
});

Only the child's beforeCapture is working.

Expected Result

Both tags should be set: Child and parent.

Actual Result

Only the child withErrorBoundary is catching the error. The parent ignores it.

Alternative

Could this be a solution, if added to every child? This way the children would set the tag and whenever there is an error, the parent would react with withErrorBoundary.

useEffect(() => {
    Sentry.configureScope((scope) => {
      scope.setTag("location", "checkout");
    });
  }, []);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Waiting for: Product Owner

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions