示例#1
0
 /**
  * {@inheritdoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     /** @var ApplicationInterface $app */
     $app = $e->getTarget();
     $serviceManager = $app->getServiceManager();
     /** @var Options $options */
     $options = $serviceManager->get('BuggymanOptions');
     if ($options->getEnabled() && $options->getToken()) {
         Buggyman::setToken($options->getToken());
         Buggyman::setErrorLevel($options->getErrorLevel());
         Buggyman::setRoot(getcwd());
         Buggyman::init();
         $app->getEventManager()->attach([MvcEvent::EVENT_DISPATCH_ERROR, MvcEvent::EVENT_RENDER_ERROR], function (MvcEvent $event) use($serviceManager) {
             if ($event->getParam('exception') instanceof Exception) {
                 Buggyman::reportException($event->getParam('exception'));
             }
         });
         if ($options->getPublicToken() && !isset($_SERVER['HTTPS'])) {
             /** @var HelperPluginManager $pluginManager */
             $pluginManager = $serviceManager->get('ViewHelperManager');
             /** @var InlineScript $inline */
             $inline = $pluginManager->get('InlineScript');
             $inline($inline::FILE, 'http://cdn.buggyman.io/v1/js/' . $options->getPublicToken() . '/collector.js');
         }
     }
 }
示例#2
0
 public function testSendReport()
 {
     $report = Buggyman::exceptionToArray(new \RuntimeException('Test exception'));
     $report['meta'] = array('test' => 'hi!');
     $report['root'] = dirname(__DIR__);
     Buggyman::setToken('2aepGEj3Jt6YhkKKzvNdgtXW8o7cDAnkZwWNO6kl');
     $result = Buggyman::sendReport(array($report));
     $this->assertEquals('{"status":"1"}', $result);
 }