You are here

raven.install in Raven: Sentry Integration 3.x

Requirements for Raven module.

File

raven.install
View source
<?php

/**
 * @file
 * Requirements for Raven module.
 */
use Sentry\Event;
use Sentry\SentrySdk;

/**
 * Implements hook_requirements().
 */
function raven_requirements($phase) {
  $requirements['raven_library']['title'] = t('Sentry PHP SDK');
  if (class_exists(SentrySdk::class) && method_exists(Event::class, 'createEvent')) {
    $event = Event::createEvent();
    $requirements['raven_library']['value'] = $event
      ->getSdkVersion();
    if ($phase == 'runtime' && ($client = SentrySdk::getCurrentHub()
      ->getClient())) {
      if ($client
        ->getOptions()
        ->getEnvironment()) {
        $requirements['raven_environment'] = [
          'title' => t('Sentry environment'),
          'value' => $client
            ->getOptions()
            ->getEnvironment(),
        ];
      }
      if ($client
        ->getOptions()
        ->getRelease()) {
        $requirements['raven_release'] = [
          'title' => t('Sentry release'),
          'value' => $client
            ->getOptions()
            ->getRelease(),
        ];
      }
    }
  }
  else {
    $requirements['raven_library']['description'] = t('Sentry PHP SDK version 3.x is required by Raven module, but is not available. Run <code>composer require drupal/raven</code> to install dependencies automatically (or <code>composer require sentry/sdk:^3</code> to install the missing SDK only).');
    $requirements['raven_library']['severity'] = REQUIREMENT_ERROR;
    $requirements['raven_library']['value'] = t('Not found');
  }
  $requirements['raven_trace']['title'] = t('Sentry reflection tracing');
  if (\Drupal::config('raven.settings')
    ->get('trace')) {
    $requirements['raven_trace']['description'] = t('Sentry reflection tracing is enabled, which may result in sensitive data being logged by Sentry.');
    $requirements['raven_trace']['value'] = t('Enabled');
  }
  else {
    $requirements['raven_trace']['value'] = t('Disabled');
  }
  return $requirements;
}

/**
 * Remove obsolete polyfill_promise config.
 */
function raven_update_8201() {
  \Drupal::configFactory()
    ->getEditable('raven.settings')
    ->clear('polyfill_promise')
    ->save();
}

Functions

Namesort descending Description
raven_requirements Implements hook_requirements().
raven_update_8201 Remove obsolete polyfill_promise config.