新的遗物浏览器找不到名称newRelic

发布于 2025-01-21 15:22:27 字数 694 浏览 5 评论 0 原文

我正在使用新的Relic浏览器报告我的React应用程序中的错误。最近,我从 react-error-boundary 软件包中介绍了 errorboundary 组件,该软件包似乎阻止了将任何错误发送给新遗物,我必须使用custic onerror 方法,像这样:

  ...
  const onError = (error: Error) => {
    newrelic.noticeError(error);
  };

  return (
    <Router>
      <Layout>
        <ErrorBoundary FallbackComponent={FallbackComponent} onError={onError}>
          <Layout>
            ...
          </Layout>
        </ErrorBoundary>
    </Router>
  );
   ....

但是我无法使这种新的调用工作,现在我有一个问题说:找不到名称'newrelic'。如何使Typescript识别我当新Relic与开发人员共享NPM软件包时,NewRelic是否在上下文中?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的奇迹 2025-01-28 15:22:27

我也有这个错误。我从其他GIST 。或者,您可以直接转到 https://github.com/肯定/肯定的/tree/tree/master/types/new-Relic-browser 。从 index.d.ts 中将值复制到您的欲望位置,也不要忘记设置 tsconfig.json ,使用key files

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 setup tsconfig.json with key files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文