【问题标题】:How can I open the user feedback window in my simulator using @sentry/react-native如何使用@sentry/react-native 在我的模拟器中打开用户反馈窗口
【发布时间】:2020-05-09 09:44:48
【问题描述】:

我需要使用@sentry/react-native 在我的模拟器中打开用户反馈窗口。

我已经厌倦了在我的 App.js 中添加 Sentry.showReportDialog()。

但它不起作用,我得到了一个未定义的错误。

谁能建议在@sentry/react-native 中打开用户反馈窗口的最佳做法是什么?

【问题讨论】:

    标签: react-native react-native-android react-native-ios sentry react-native-sentry


    【解决方案1】:

    我认为反馈窗口仅适用于您可以在此线程中阅读的浏览器 https://github.com/getsentry/sentry-react-native/issues/500 作为一个选项,您可以通过反馈 API 放置它并制作您自己的全局模式/警报

    Sentry.init({
        dsn: 'key',
        beforeSend(event, hint) {
          // Check if it is an exception, and if so, show the report dialog
          if (event.exception) {
            Sentry.showReportDialog({ eventId: event.event_id });
          }
          return event;
        }
    });
    

    sentry api 反馈示例

    let endpoint = 'https://sentry.io/api/0/projects/{your_organization_slug}/{your_project_slug}/user-feedback/'
    
    let params = {
      event_id: ...,
      name: 'John Smith',
      email: 'johnsmith@example.com',
      comments: 'This app sucks'
    }
    
    try {
      await fetch(endpoint, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(params)
      })
      console.log('Feedback submitted!')
    } catch (error) {
      console.error(error)
    }
    

    【讨论】:

    • 如果我使用上面的,我可以在ios(模拟器)和android中显示
    • 不,只能在浏览器中使用。你可以阅读 github 线程,有一个你想要的功能请求。但是如果你需要它,你可以使用反馈 API 来注册事件并显示一些 ui 警报
    • 所以我可以使用这个 API 在移动应用中获取反馈。所以我现在需要自定义弹出窗口。我说的对吗?
    • 使用 api,您可以将用户的反馈发送到您的哨兵仪表板。因此,为了实现这一点,您应该向哨兵反馈 api 发送一个发布请求。你可以检查我的编辑
    • 你能在世博会上举出任何例子吗?创建 lastEventId 时出现错误
    猜你喜欢
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 2020-07-23
    • 1970-01-01
    • 2019-05-07
    • 2016-11-08
    • 2017-07-22
    • 1970-01-01
    相关资源
    最近更新 更多