I am using New Relic Browser to report error in my React application. Recently I introduced ErrorBoundary component from react-error-boundary package that seems to block sending any error to New Relic and I have to do it with custom onError method, like this:
...
const onError = (error: Error) => {
newrelic.noticeError(error);
};
return (
<Router>
<Layout>
<ErrorBoundary FallbackComponent={FallbackComponent} onError={onError}>
<Layout>
...
</Layout>
</ErrorBoundary>
</Router>
);
....
But I'm not able to make this newrelic invoke work, now I've got an issue saying: Cannot find name 'newrelic'. How to make Typescript recognize that I have newrelic in the context when there is no npm package that New Relic shares with developers?
I also got this error. I found solution from other gist https://gist.github.com/piotrkubisa/4a1cc7355afcec46651a896d59ec8d50. Or you can directly go to https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/new-relic-browser . copy the value from
index.d.ts
to your desire location, also don't forget setuptsconfig.json
with keyfiles
.