找不到名字 SentrySibling

问题描述 投票:0回答:1

我有一个用 Capacitor 包装的 React 应用程序。尝试按照“入门”页面安装哨兵。

它说要做:

npm install --save @sentry/capacitor @sentry/react@^7

然后将此代码复制粘贴到我的应用程序中:

import * as Sentry from '@sentry/capacitor';
import * as SentryReact from '@sentry/react';

Sentry.init({
    dsn:"https://xxxxxxxxx.ingest.us.sentry.io/xxxxxxxxxxxx",
    integrations: [
      SentrySibling.browserTracingIntegration(),
      new SentryReact.BrowserTracing({
      // Set 'tracePropagationTargets' to control for which URLs distributed 
         tracing should be enabled
     tracePropagationTargets: ["localhost",/^https:\/\/yourserver\.io\/api/],
     }),
     new SentryReact.Replay(),
   ],
    // Tracing
    tracesSampleRate: 1.0, //  Capture 100% of the transactions
   // Session Replay
   replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You 
   may want to change it to 100% while in development and then sample at a 
   lower rate in production.
   replaysOnErrorSampleRate: 1.0, // If you're not already sampling the 
   entire session, change the sample rate to 100% when sampling sessions 
   where errors occur.
   },
   // Forward the init method from @sentry/react
   SentryReact.init
);

添加了一张图片以使其清楚: sentry-copy-past-code

这是我在 IDE 中看到的:

ide

问题:

  • new SentryReact.BrowserTracing
    已弃用
  • SentrySibling
    没有导入(并且在文档中找不到它)
  • Replay
    已弃用。

我错过了什么?

reactjs capacitor sentry
1个回答
0
投票

@sentry/react 中的 BrowserTracing 集成已被弃用,取而代之的是 @sentry/tracing 中的 Tracing 或 BrowserTracing。

您可以尝试下面的代码吗?

import { init as sentryInit } from '@sentry/capacitor';
import { BrowserTracing } from '@sentry/tracing';
import { Replay } from '@sentry/react';

sentryInit({
  dsn: "https://xxxxxxxxx.ingest.us.sentry.io/xxxxxxxxxxxx",
  integrations: [
    new BrowserTracing({
      tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
    }),
    new Replay(),
  ],
  tracesSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});
© www.soinside.com 2019 - 2024. All rights reserved.