function raven_library in Raven: Sentry Integration 7.4
Same name and namespace in other branches
- 7.2 raven.module \raven_library()
- 7.3 raven.module \raven_library()
Implements hook_library().
File
- ./
raven.module, line 95 - 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"] = [];
$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 ($tracesSampleRate = variable_get('raven_js_traces_sample_rate', NULL)) {
$options->tracesSampleRate = (double) $tracesSampleRate;
}
$options->integrations = [];
$libraries['raven']['js'][] = [
'data' => [
'raven' => [
// Other modules can alter the @sentry/browser options.
'options' => $options,
'user' => [
'id' => $user->uid,
],
],
],
'type' => 'setting',
];
$libraries['raven']['js']["{$path}/js/raven.js"] = [
// Load in the footer to ensure settings are available.
'scope' => 'footer',
];
return $libraries;
}