Tracking errors for an embeddable script

I’m writing an embeddable script that creates a popup on my customers’ websites.

I want to track errors that occur within the popup, but not errors that are due to the websites that host it.

Because it’s a React app, I’m looking for a way to only include errors that follow from ReactDOM.render(...).

Here’s what I’m looking for, expressed as pseudo-code:

Sentry.init({
    dsn: "...",
    captureAllErrors: false
})

Sentry.captureErrorsWithin(() => {
  ReactDOM.render(
    <RootComponent />,
    document.getElementById(ROOT_NODE)
  );
})

function RootComponent () {
  throw new Error("This SHOULD be picked up by sentry")
}

throw new Error("This should NOT be picked up by Sentry")