You are here

function raven_library in Raven: Sentry Integration 7.3

Same name and namespace in other branches
  1. 7.4 raven.module \raven_library()
  2. 7.2 raven.module \raven_library()

Implements hook_library().

File

./raven.module, line 99
Allows to track errors to Sentry server.

Code

function raven_library() {
  global $user;
  $libraries['raven']['version'] = '6.12.0';
  $path = drupal_get_path('module', 'raven');
  $libraries['raven']['js']["{$path}/js/bundle.tracing.min.js"] = array();
  $options = new stdClass();
  $options->dsn = empty($_SERVER['SENTRY_DSN']) ? variable_get('raven_public_dsn', '') : $_SERVER['SENTRY_DSN'];
  if ($environment = empty($_SERVER['SENTRY_ENVIRONMENT']) ? variable_get('raven_environment') : $_SERVER['SENTRY_ENVIRONMENT']) {
    $options->environment = $environment;
  }
  if ($release = empty($_SERVER['SENTRY_RELEASE']) ? variable_get('raven_release') : $_SERVER['SENTRY_RELEASE']) {
    $options->release = $release;
  }
  $options->autoSessionTracking = variable_get('raven_auto_session_tracking', FALSE);
  $options->sendClientReports = variable_get('raven_send_client_reports', FALSE);
  if ($traces_sample_rate = variable_get('raven_js_traces_sample_rate', NULL)) {
    $options->tracesSampleRate = (double) $traces_sample_rate;
  }
  $options->integrations = array();
  $libraries['raven']['js'][] = array(
    'data' => array(
      'raven' => array(
        // Other modules can alter the @sentry/browser options.
        'options' => $options,
        'user' => array(
          'id' => $user->uid,
        ),
      ),
    ),
    'type' => 'setting',
  );
  $libraries['raven']['js']["{$path}/js/raven.js"] = array(
    // Load in the footer to ensure settings are available.
    'scope' => 'footer',
  );
  return $libraries;
}