SanitizeStacktraceProcessor.php 1008 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of Raven.
  4. *
  5. * (c) Sentry Team
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * This processor removes the `pre_context`, `context_line` and `post_context`
  12. * informations from all exceptions captured by an event.
  13. *
  14. * @author Stefano Arlandini <sarlandini@alice.it>
  15. */
  16. class Raven_Processor_SanitizeStacktraceProcessor extends Raven_Processor
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function process(&$data)
  22. {
  23. if (!isset($data['exception'], $data['exception']['values'])) {
  24. return;
  25. }
  26. foreach ($data['exception']['values'] as &$exception) {
  27. if (!isset($exception['stacktrace'])) {
  28. continue;
  29. }
  30. foreach ($exception['stacktrace']['frames'] as &$frame) {
  31. unset($frame['pre_context'], $frame['context_line'], $frame['post_context']);
  32. }
  33. }
  34. }
  35. }