设置用户反馈

了解更多关于事件发生时收集用户反馈的信息。Sentry 将反馈与原始事件配对,为您提供更多问题的洞察。

用户反馈 API 允许您在使用自己的 UI 时收集用户反馈。您可以使用应用程序中相同的编程语言发送用户反馈。在这种情况下,SDK 会创建 HTTP 请求,因此您无需通过 HTTP 发送数据。

Sentry 会将反馈与原始事件配对,为您提供更多问题的洞察。Sentry 需要 eventId 才能将用户反馈关联到相应的事件。例如,要获取 eventId,您可以使用 beforeSend或捕获事件方法的返回值。

Copied
import * as Sentry from "@sentry/react-native";
import { UserFeedback } from "@sentry/react-native";

const sentryId = Sentry.captureMessage("My Message");
// OR: const sentryId = Sentry.lastEventId();

const userFeedback: UserFeedback = {
  event_id: sentryId,
  name: "John Doe",
  email: "john@doe.com",
  comments: "Hello World!",
};

Sentry.captureUserFeedback(userFeedback);