【问题标题】:How to customize user feedback in Sentry?如何在 Sentry 中自定义用户反馈?
【发布时间】:2016-11-01 01:53:16
【问题描述】:

如何在 Sentry 中自定义用户反馈表?

默认情况下会说“看起来我们遇到了一些内部问题”。

是否可以更改消息、收集的数据等?

谢谢。

【问题讨论】:

    标签: sentry


    【解决方案1】:

    有一个 API here,但你必须得到一个 event_id,它基本上是由你的应用程序中的错误或异常生成的......我仍在试图弄清楚如何在没有默认集成表单。

    【讨论】:

      【解决方案2】:

      Sentry 有一个内置的前端用户反馈表单,您可以在一定程度上触发和自定义。 Angular4+ 中的基本实现可能如下所示:

      import { ErrorHandler } from '@angular/core';
      import { Config } from '../config/config';
      import * as Sentry from '@sentry/browser';
      
      Sentry.init({
        dsn: 'https://0123456789abcdef.sentry.io/000001', 
        release: Config.SENTRY_RELEASE
      });
      
      export class SentryErrorHandler implements ErrorHandler {
        handleError(error: any): void {
          const eventId = Sentry.captureException(error.originalError || error);
          Sentry.showReportDialog({
            eventId,
            title: 'Aw, Snap! You broke the internet!',
            subtitle: 'Send us an email and we will fix it.',
            subtitle2: 'Please refresh your cache to continue (cmd+R / ctrl+R)'
          });
        }
      }
      
      

      Here's a link to the showReportDialog API

      【讨论】:

      • 您也可以在仪表板 https://sentry.io/settings/[YOUR_TEAM]/projects/[YOUR_PROJECT]/user-feedback/ 中关闭 Sentry 品牌
      • 是否支持移动应用
      【解决方案3】:

      目前看来是这样的:

      • 制作您自己的用户界面
      • 生成 Sentry 事件并将其排入队列(如果尚未发送偶数也可以)
      • POST 到 Sentry 的报告收集器使用的特殊端点

      详情见https://github.com/getsentry/sentry-javascript/issues/3111

      const dsn = SENTRY_DSN;
      const eventId = captureMessage("User report");
      
      const query = Object.entries({dsn, eventId})
        .map(([k, v]) => `${ k }=${ encodeURIComponent(v) }`).join("&");
      
      const body = new FormData();
      Object.entries(
        {name: "Alex Foo", email: "a.foo@example.com", comments: "Long text goes here"})
        .map(([k, v]) => body.append(k, v));
      
      fetch(`https://sentry.io/api/embed/error-page/?${ query }`,
        {method: "POST", body});
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-31
        • 1970-01-01
        • 1970-01-01
        • 2021-01-13
        • 2020-05-09
        • 1970-01-01
        相关资源
        最近更新 更多