You are here

function raven_page_build in Raven: Sentry Integration 7

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

Implements hook_page_build().

File

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

Code

function raven_page_build(&$page) {
  global $user;
  if (variable_get('raven_js_enabled', FALSE) && user_access('send javascript errors to sentry')) {
    if (variable_get('raven_js_source', 'cdn') == 'cdn') {
      drupal_add_js(variable_get('raven_js_cdn_url', RAVEN_JS_CDN_URL), array(
        'type' => 'external',
        'group' => JS_LIBRARY,
      ));
    }
    drupal_add_js(array(
      'raven' => array(
        'dsn' => variable_get('raven_public_dsn', ''),
        // Other modules can alter the Raven.js options.
        'options' => new stdClass(),
        'user' => array(
          'id' => $user->uid,
        ),
      ),
    ), 'setting');
    drupal_add_js(drupal_get_path('module', 'raven') . '/raven.js', array(
      'group' => JS_LIBRARY,
      'scope' => 'footer',
      'every_page' => TRUE,
    ));
  }
}