RemoveExceptionFrameVarsIntegration.php in Raven: Sentry Integration 3.x
File
src/Integration/RemoveExceptionFrameVarsIntegration.php
View source
<?php
declare (strict_types=1);
namespace Drupal\raven\Integration;
use Sentry\Event;
use Sentry\Integration\IntegrationInterface;
use Sentry\Options;
use Sentry\SentrySdk;
use Sentry\State\Scope;
class RemoveExceptionFrameVarsIntegration implements IntegrationInterface {
public function setupOnce() : void {
Scope::addGlobalEventProcessor(function (Event $event) : Event {
$currentHub = SentrySdk::getCurrentHub();
$integration = $currentHub
->getIntegration(self::class);
$client = $currentHub
->getClient();
if (NULL === $integration || NULL === $client) {
return $event;
}
$this
->processEvent($event, $client
->getOptions());
return $event;
});
}
private function processEvent(Event $event, Options $options) : void {
foreach ($event
->getExceptions() as $exception) {
foreach ($exception
->getStacktrace()
->getFrames() as $frame) {
$frame
->setVars([]);
}
}
}
}