You are here

raven.admin.inc in Raven: Sentry Integration 7.3

Same filename and directory in other branches
  1. 7.4 raven.admin.inc
  2. 7 raven.admin.inc
  3. 7.2 raven.admin.inc

Contains the administration pages for Raven.

File

raven.admin.inc
View source
<?php

/**
 * @file
 * Contains the administration pages for Raven.
 */

/**
 * Adds Raven settings form to form.
 *
 * @param array $form
 *   The form definition.
 * @param array $form_state
 *   The form state.
 */
function raven_settings_form(array &$form, array &$form_state) {
  $form['raven'] = array(
    '#type' => 'fieldset',
    '#title' => t('Sentry'),
    '#collapsible' => TRUE,
  );
  $form['raven']['client'] = array(
    '#type' => 'fieldset',
    '#title' => t('Browser'),
    '#collapsible' => TRUE,
  );
  $form['raven']['client']['raven_public_dsn'] = array(
    '#type' => 'textfield',
    '#title' => t('Sentry DSN'),
    '#description' => t('Sentry DSN credentials for current site. This setting can be overridden with the SENTRY_DSN environment variable.'),
    '#default_value' => variable_get('raven_public_dsn', ''),
  );
  $form['raven']['client']['raven_js_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Sentry JavaScript handler'),
    '#description' => t('Check to send client-side JavaScript exceptions to Sentry (if user has the <a target="_blank" href="@url"><em>send JavaScript errors to Sentry</em> permission</a>).', array(
      '@url' => url('admin/people/permissions', array(
        'fragment' => 'module-raven',
      )),
    )),
    '#default_value' => variable_get('raven_js_enabled', FALSE),
  );
  $form['raven']['client']['raven_js_traces_sample_rate'] = array(
    '#type' => 'textfield',
    '#title' => t('Browser performance tracing sample rate'),
    '#description' => t('Set the browser performance tracing sample rate, or set to 0 to disable performance tracing.'),
    '#default_value' => variable_get('raven_js_traces_sample_rate', NULL),
    '#element_validate' => array(
      'element_validate_number',
    ),
  );
  $form['raven']['client']['raven_auto_session_tracking'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable auto session tracking'),
    '#description' => t('Check to monitor release health by sending a session event to Sentry for each page load; only active if a release is specified below or via the SENTRY_RELEASE environment variable.'),
    '#default_value' => variable_get('raven_auto_session_tracking', FALSE),
  );
  $form['raven']['client']['raven_send_client_reports'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send client reports'),
    '#description' => t('Send client report (e.g. number of discarded events), if any, when tab is hidden or closed.'),
    '#default_value' => variable_get('raven_send_client_reports', FALSE),
  );
  $form['raven']['client']['raven_set_report_uri'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send security header reports to Sentry'),
    '#description' => t('Check this and install <a href="@url">Security Kit module</a> to send CSP and CT reports to Sentry.', array(
      '@url' => module_exists('seckit') ? url('admin/config/system/seckit') : 'https://www.drupal.org/project/seckit',
    )),
    '#default_value' => variable_get('raven_set_report_uri', FALSE),
    '#disabled' => !module_exists('seckit'),
  );
  $form['raven']['raven_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Sentry PHP handler'),
    '#description' => t('Check to send events in server-side PHP code to Sentry.'),
    '#default_value' => variable_get('raven_enabled', FALSE),
  );
  $form['raven']['php'] = array(
    '#type' => 'fieldset',
    '#title' => t('PHP'),
    '#collapsible' => TRUE,
    '#collapsed' => !variable_get('raven_enabled', FALSE),
    '#states' => array(
      'collapsed' => array(
        ':input[name="raven_enabled"]' => array(
          'unchecked' => TRUE,
        ),
      ),
    ),
  );
  $form['raven']['php']['raven_dsn'] = array(
    '#type' => 'textfield',
    '#title' => t('Sentry DSN'),
    '#description' => t('Sentry DSN credentials for current site. This setting can be overridden with the SENTRY_DSN environment variable.'),
    '#default_value' => variable_get('raven_dsn', ''),
  );
  $form['raven']['php']['connection'] = array(
    '#type' => 'fieldset',
    '#title' => t('Connection settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['raven']['php']['connection']['raven_timeout'] = array(
    '#type' => 'textfield',
    '#title' => t('Timeout'),
    '#description' => t('Connection timeout in seconds.'),
    '#default_value' => variable_get('raven_timeout', 2),
    '#size' => 10,
  );
  $form['raven']['php']['connection']['raven_ssl'] = array(
    '#type' => 'radios',
    '#title' => t('SSL Verification'),
    '#default_value' => variable_get('raven_ssl', 'verify_ssl'),
    '#options' => array(
      'verify_ssl' => t('Verify SSL'),
      'ca_cert' => t('Verify against a CA certificate'),
      'no_verify_ssl' => t("Don't verify SSL (not recommended)"),
    ),
  );
  $form['raven']['php']['connection']['raven_ca_cert'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to CA certificate'),
    '#default_value' => variable_get('raven_ca_cert', ''),
    '#description' => t('Path to the CA certificate file of the Sentry server specified in the DSN.'),
    '#states' => array(
      'visible' => array(
        ':input[name=raven_ssl]' => array(
          'value' => 'ca_cert',
        ),
      ),
    ),
  );
  $form['raven']['php']['raven_fatal_error_handler'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable fatal error handler'),
    '#description' => t('Check to handle fatal PHP errors.'),
    '#default_value' => variable_get('raven_fatal_error_handler', TRUE),
  );
  $form['raven']['php']['raven_fatal_error_handler_memory'] = array(
    '#type' => 'textfield',
    '#title' => t('Reserved memory'),
    '#description' => t('Reserved memory for fatal error handler (KB).'),
    '#default_value' => variable_get('raven_fatal_error_handler_memory', 2.5 * 1024),
    '#size' => 10,
  );
  foreach (watchdog_severity_levels() as $level => $label) {
    $watchdog_levels[$level + 1] = $label;
  }
  $form['raven']['php']['raven_watchdog_levels'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Message levels'),
    '#description' => t('Check message levels to handle.'),
    '#default_value' => variable_get('raven_watchdog_levels', array()),
    '#options' => $watchdog_levels,
  );
  $form['raven']['php']['raven_ignored_types'] = array(
    '#type' => 'textarea',
    '#title' => t('Ignored types'),
    '#description' => t('A list of log event types for which messages should not be sent to Sentry (one type per line). Commonly-configured types include <em>access denied</em> for 403 errors and <em>page not found</em> for 404 errors.'),
    '#default_value' => variable_get('raven_ignored_types', ''),
  );
  $form['raven']['php']['raven_message_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Message limit'),
    '#description' => t('Log message maximum length in characters.'),
    '#default_value' => variable_get('raven_message_limit', 2048),
    '#size' => 10,
  );
  $form['raven']['php']['raven_stack'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable stacktraces'),
    '#description' => t('Enable it to add stacktraces to reports.'),
    '#default_value' => variable_get('raven_stack', TRUE),
  );
  $form['raven']['php']['raven_trace'] = array(
    '#type' => 'checkbox',
    '#title' => t('Reflection tracing in stacktraces'),
    '#description' => t('Check this to enable reflection tracing (function calling arguments) in stacktraces. Warning: This setting allows sensitive data to be logged by Sentry!'),
    '#default_value' => variable_get('raven_trace', FALSE),
  );
  $form['raven']['php']['raven_trace_user'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable reflection tracing for user watchdog messages'),
    '#description' => t('Check this to enable reflection tracing of user watchdog messages. This is disabled by default to avoid logging user passwords.'),
    '#default_value' => variable_get('raven_trace_user', FALSE),
  );
  $form['raven']['raven_environment'] = array(
    '#type' => 'textfield',
    '#title' => t('Environment'),
    '#description' => t('The environment in which this site is running. This setting can be overridden with the SENTRY_ENVIRONMENT environment variable.'),
    '#default_value' => variable_get('raven_environment', ''),
  );
  $form['raven']['raven_release'] = array(
    '#type' => 'textfield',
    '#title' => t('Release'),
    '#description' => t('The release this site is running (could be a version or commit hash). This setting can be overridden with the SENTRY_RELEASE environment variable.'),
    '#default_value' => variable_get('raven_release', ''),
  );
}

Functions

Namesort descending Description
raven_settings_form Adds Raven settings form to form.