function raven_seckit_options_alter in Raven: Sentry Integration 7.3
Same name and namespace in other branches
- 7.4 raven.module \raven_seckit_options_alter()
Implements hook_seckit_options_alter().
File
- ./
raven.module, line 467 - Allows to track errors to Sentry server.
Code
function raven_seckit_options_alter(&$options) {
if (!class_exists('Raven_Client')) {
return;
}
try {
$dsn = Raven_Client::parseDSN(empty($_SERVER['SENTRY_DSN']) ? variable_get('raven_public_dsn') : $_SERVER['SENTRY_DSN']);
} catch (InvalidArgumentException $e) {
// Raven is incorrectly configured.
return;
}
$query = array(
'sentry_key' => $dsn['public_key'],
);
if ($environment = empty($_SERVER['SENTRY_ENVIRONMENT']) ? variable_get('raven_environment') : $_SERVER['SENTRY_ENVIRONMENT']) {
$query['sentry_environment'] = $environment;
}
if ($release = empty($_SERVER['SENTRY_RELEASE']) ? variable_get('raven_release') : $_SERVER['SENTRY_RELEASE']) {
$query['sentry_release'] = $release;
}
$url = url(str_replace('/store/', '/security/', $dsn['server']), array(
'query' => $query,
));
if (variable_get('raven_set_report_uri')) {
$options['seckit_ct']['report-uri'] = $url;
$options['seckit_xss']['csp']['report-uri'] = $url;
}
if (variable_get('raven_js_enabled', FALSE)) {
$options['seckit_xss']['csp']['connect-src'] .= $options['seckit_xss']['csp']['connect-src'] ? " {$dsn['server']} " : "{$options['seckit_xss']['csp']['default-src']} {$dsn['server']} ";
$options['seckit_xss']['csp']['connect-src'] .= str_replace('/store/', '/envelope/', $dsn['server']);
}
}