Commit dfa75edf authored by mark burdett's avatar mark burdett
Browse files

Issue #3278847 by mfb: Provide a setting to send user feedback to Sentry

parent fb2ffe82
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,3 +29,4 @@ seckit_set_report_uri: false
send_attempts: 0
send_monitoring_sensor_status_changes: false
404_tracing: false
show_report_dialog: false
+3 −0
Original line number Diff line number Diff line
@@ -123,3 +123,6 @@ raven.settings:
    404_tracing:
      type: boolean
      label: '404 response performance tracing'
    show_report_dialog:
      type: boolean
      label: 'Show user feedback dialog'
+10 −0
Original line number Diff line number Diff line
@@ -10,6 +10,16 @@
  // Add the browser performance tracing integration.
  drupalSettings.raven.options.integrations.push(new Sentry.Integrations.BrowserTracing());

  // Show report dialog via beforeSend callback, if enabled.
  if (drupalSettings.raven.showReportDialog) {
    drupalSettings.raven.options.beforeSend = function (event, hint) {
      if (event.exception) {
        Sentry.showReportDialog({ eventId: event.event_id, lang: drupalSettings.path.currentLanguage });
      }
      return event;
    };
  }

  // Additional Sentry configuration can be applied by modifying
  // drupalSettings.raven.options in custom PHP or JavaScript. Use the latter
  // for Sentry callback functions; library weight can be used to ensure your
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ function raven_page_attachments(array &$page) {
  }
  $page['#attached']['drupalSettings']['raven']['options']->autoSessionTracking = $config->get('auto_session_tracking');
  $page['#attached']['drupalSettings']['raven']['options']->sendClientReports = $config->get('send_client_reports');
  $page['#attached']['drupalSettings']['raven']['showReportDialog'] = $config->get('show_report_dialog');
  $page['#attached']['library'][] = 'raven/raven';
  // Add performance tracing meta tag for attaching traces to errors.
  if (!class_exists(SentrySdk::class) || !SentrySdk::getCurrentHub()->getSpan()) {
+8 −0
Original line number Diff line number Diff line
@@ -69,6 +69,12 @@ class RavenConfigForm {
      '#default_value'  => $config->get('seckit_set_report_uri'),
      '#disabled'       => !\Drupal::moduleHandler()->moduleExists('seckit'),
    ];
    $form['raven']['js']['show_report_dialog'] = [
      '#type'           => 'checkbox',
      '#title'          => t('Show user feedback dialog'),
      '#description'    => t('Check to allow users to submit a report to Sentry when JavaScript exceptions are thrown.'),
      '#default_value'  => $config->get('show_report_dialog'),
    ];
    $form['raven']['php'] = [
      '#type'           => 'details',
      '#title'          => t('PHP'),
@@ -309,6 +315,8 @@ class RavenConfigForm {
        $form_state->getValue(['raven', 'js', 'send_client_reports']))
      ->set('seckit_set_report_uri',
        $form_state->getValue(['raven', 'js', 'seckit_set_report_uri']))
      ->set('show_report_dialog',
        $form_state->getValue(['raven', 'js', 'show_report_dialog']))
      ->set('environment',
        $form_state->getValue(['raven', 'environment']))
      ->set('release',