From eaad5404adc2ea751cbd819578c18a6bae764227 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Fri, 2 Nov 2018 20:29:59 -0300 Subject: [PATCH 1/7] testing and playing around with breadcrumbs --- Site/SiteApplication.php | 14 ++++++++++ Site/SiteWebApplication.php | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Site/SiteApplication.php b/Site/SiteApplication.php index e517a338..a89f1ea0 100644 --- a/Site/SiteApplication.php +++ b/Site/SiteApplication.php @@ -1092,6 +1092,20 @@ public static function initVar($name, $default = null, $types = 0) return $var; } + // }}} + // {{{ public function addSentryBreadcrumb() + + public function addSentryBreadcrumb($message, $category) + { + $result = $this->sentry_client->breadcrumbs->record([ + 'message' => $message, + 'category' => $category, + 'level' => 'error' + ]); + + print('BREADCRUMBS RESULT IS:
' .print_r($result,1).'
' ); + } + // }}} } diff --git a/Site/SiteWebApplication.php b/Site/SiteWebApplication.php index cea10cea..637b8fed 100644 --- a/Site/SiteWebApplication.php +++ b/Site/SiteWebApplication.php @@ -136,6 +136,8 @@ public function run() } } + $sentryCategory = 'application page steps'; + try { if (!$cached) { $page_data = array(); @@ -143,15 +145,33 @@ public function run() $this->setP3PHeaders(); $this->loadPage(); + $this->page->layout->init(); + $this->addSentryBreadcrumb('page layout init()', $sentryCategory); + $this->page->init(); + $this->addSentryBreadcrumb('page init()', $sentryCategory); + $this->page->layout->process(); + $this->addSentryBreadcrumb('page layout process()', $sentryCategory); + $this->page->process(); + $this->addSentryBreadcrumb('page process()', $sentryCategory); + $this->page->layout->build(); + $this->addSentryBreadcrumb('page layout build()', $sentryCategory); + $this->page->build(); + $this->addSentryBreadcrumb('page build()', $sentryCategory); + $this->page->layout->finalize(); + $this->addSentryBreadcrumb('page layout finalize()', $sentryCategory); + $this->page->finalize(); + $this->addSentryBreadcrumb('page finalize()', $sentryCategory); + $this->page->layout->complete(); + $this->addSentryBreadcrumb('page layout complete()', $sentryCategory); // get page content ob_start(); @@ -198,6 +218,7 @@ public function run() // display exception page (never cached) $this->page->layout->display(); + $this->addSentryBreadcrumb('exception page displayed', $sentryCategory); } } @@ -1178,6 +1199,38 @@ private function hasSession() $this->session->isActive()); } + + // }}} + // {{{ protected function getServerName() + + /** + * Gets the servername + * + * @param string the page step type + */ + protected function recordPageStep($type) + { + $server_name = $_SERVER['HTTP_HOST']; + + if ($secure !== null && $this->secure !== $secure) { + /* Need to mangle servername for browsers tunnelling on + * non-standard ports. + */ + $regexp = '/localhost:[0-9]+/u'; + + if (preg_match($regexp, $server_name)) { + if ($secure) { + $server_name = 'localhost:8443'; + } else { + $server_name = 'localhost:8080'; + } + } + } + + return $server_name; + } + + // }}} } From cc4fe2ce52a6cfdf308cc6b6597dbf3a2abd9263 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Thu, 8 Nov 2018 14:04:39 -0400 Subject: [PATCH 2/7] simplifying application page step breadcrumb names --- Site/SiteWebApplication.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Site/SiteWebApplication.php b/Site/SiteWebApplication.php index 637b8fed..f5058406 100644 --- a/Site/SiteWebApplication.php +++ b/Site/SiteWebApplication.php @@ -147,31 +147,31 @@ public function run() $this->loadPage(); $this->page->layout->init(); - $this->addSentryBreadcrumb('page layout init()', $sentryCategory); + $this->addSentryBreadcrumb('layout init()', $sentryCategory); $this->page->init(); - $this->addSentryBreadcrumb('page init()', $sentryCategory); + $this->addSentryBreadcrumb('init()', $sentryCategory); $this->page->layout->process(); - $this->addSentryBreadcrumb('page layout process()', $sentryCategory); + $this->addSentryBreadcrumb('layout process()', $sentryCategory); $this->page->process(); - $this->addSentryBreadcrumb('page process()', $sentryCategory); + $this->addSentryBreadcrumb('process()', $sentryCategory); $this->page->layout->build(); - $this->addSentryBreadcrumb('page layout build()', $sentryCategory); + $this->addSentryBreadcrumb('layout build()', $sentryCategory); $this->page->build(); - $this->addSentryBreadcrumb('page build()', $sentryCategory); + $this->addSentryBreadcrumb('build()', $sentryCategory); $this->page->layout->finalize(); - $this->addSentryBreadcrumb('page layout finalize()', $sentryCategory); + $this->addSentryBreadcrumb('layout finalize()', $sentryCategory); $this->page->finalize(); - $this->addSentryBreadcrumb('page finalize()', $sentryCategory); + $this->addSentryBreadcrumb('finalize()', $sentryCategory); $this->page->layout->complete(); - $this->addSentryBreadcrumb('page layout complete()', $sentryCategory); + $this->addSentryBreadcrumb('layout complete()', $sentryCategory); // get page content ob_start(); From fb9e668922601a5aadf70d602a7cc4b3038c9334 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Fri, 9 Nov 2018 13:21:47 -0400 Subject: [PATCH 3/7] breadcrumbs info instead of error, shortening category --- Site/SiteApplication.php | 4 +--- Site/SiteWebApplication.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Site/SiteApplication.php b/Site/SiteApplication.php index a89f1ea0..67bc16fa 100644 --- a/Site/SiteApplication.php +++ b/Site/SiteApplication.php @@ -1100,10 +1100,8 @@ public function addSentryBreadcrumb($message, $category) $result = $this->sentry_client->breadcrumbs->record([ 'message' => $message, 'category' => $category, - 'level' => 'error' + 'level' => 'info' ]); - - print('BREADCRUMBS RESULT IS:
' .print_r($result,1).'
' ); } // }}} diff --git a/Site/SiteWebApplication.php b/Site/SiteWebApplication.php index f5058406..fe6de389 100644 --- a/Site/SiteWebApplication.php +++ b/Site/SiteWebApplication.php @@ -136,7 +136,7 @@ public function run() } } - $sentryCategory = 'application page steps'; + $sentryCategory = 'app steps'; try { if (!$cached) { From a6e7253499c11e09d53033fe298e6250455d7032 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Fri, 9 Nov 2018 19:39:25 -0400 Subject: [PATCH 4/7] Adding SiteSentryReportDialog --- Site/SiteSentryReportDialog.php | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Site/SiteSentryReportDialog.php diff --git a/Site/SiteSentryReportDialog.php b/Site/SiteSentryReportDialog.php new file mode 100644 index 00000000..7f01bd1e --- /dev/null +++ b/Site/SiteSentryReportDialog.php @@ -0,0 +1,69 @@ +sentry_client = $sentry_client; + $this->sentry_dsn = $sentry_dsn; + } + + // }}} + // {{{ public function getInlineXhtml() + + public function getInlineXhtml() + { + $event_id = SwatString::quoteJavaScriptString( + $this->sentry_client->getLastEventID() + ); + + $sentry_dsn = SwatString::quoteJavaScriptString( + $this->sentry_dsn + ); + + $html = << + + + + +HTML; + + return sprintf( + $html, + $event_id, + $sentry_dsn + ); + } + + // }}} + } + + ?> From e5d448f248765ed3a6cc3fa4ec22680c6a3868a3 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Thu, 15 Nov 2018 19:22:09 -0400 Subject: [PATCH 5/7] adding report dialog to http error page --- Site/SiteSentryReportDialog.php | 2 +- Site/pages/SiteHttpErrorPage.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Site/SiteSentryReportDialog.php b/Site/SiteSentryReportDialog.php index 7f01bd1e..e89b6e18 100644 --- a/Site/SiteSentryReportDialog.php +++ b/Site/SiteSentryReportDialog.php @@ -3,7 +3,7 @@ /** * Generates Sentry Report Dialog for User Input * - * @package Store + * @package Site * @copyright 2018 silverorange */ class SiteSentryReportDialog diff --git a/Site/pages/SiteHttpErrorPage.php b/Site/pages/SiteHttpErrorPage.php index 4aae8e12..0bcf29b5 100644 --- a/Site/pages/SiteHttpErrorPage.php +++ b/Site/pages/SiteHttpErrorPage.php @@ -11,6 +11,11 @@ class SiteHttpErrorPage extends SitePage protected $http_status_code = null; protected $uri = null; + /** + * @var SiteSentryReportDialog + */ + protected $sentry_report_dialog; + // }}} // init phase @@ -41,6 +46,8 @@ public function init() } else { $this->uri = $_SERVER['REQUEST_URI']; } + + $this->sentry_report_dialog = new SiteSentryReportDialog(); } // }}} @@ -85,6 +92,7 @@ protected function display() $p_tag->display(); $this->displaySuggestions(); + $this->displaySentryReportDialog(); echo '

'; @@ -145,6 +153,14 @@ protected function getSuggestions() ); } + // }}} + // {{{ protected function displaySentryReportDialog() + + protected function displaySentryReportDialog() + { + echo $this->sentry_report_dialog->getInlineXhtml(); + } + // }}} // {{{ protected function sendHttpStatusHeader() From ebed534781d3c9f6cc83e0f0a7577735e66f72a6 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Thu, 15 Nov 2018 20:35:38 -0400 Subject: [PATCH 6/7] using values from siteapplication to set SiteSentryReportDialog --- Site/SiteApplication.php | 9 +++++++++ Site/SiteWebApplication.php | 1 + Site/pages/SiteExceptionPage.php | 19 +++++++++++++++++++ Site/pages/SiteHttpErrorPage.php | 16 ---------------- Site/pages/SiteXhtmlExceptionPage.php | 2 ++ 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Site/SiteApplication.php b/Site/SiteApplication.php index 67bc16fa..7a0d2a7e 100644 --- a/Site/SiteApplication.php +++ b/Site/SiteApplication.php @@ -113,6 +113,11 @@ abstract class SiteApplication extends SiteObject */ protected $sentry_client; + /** + * @var SiteSentryReportDialog + */ + protected $sentry_report_dialog; + // }}} // {{{ public function __construct() @@ -468,6 +473,10 @@ protected function setUpSentryErrorHandling(SiteConfigModule $config) $error_handler->registerShutdownFunction(); $this->sentry_client = $client; + $this->sentry_report_dialog = new SiteSentryReportDialog( + $client, + $config->sentry->dsn + ); } // }}} diff --git a/Site/SiteWebApplication.php b/Site/SiteWebApplication.php index fe6de389..076e2243 100644 --- a/Site/SiteWebApplication.php +++ b/Site/SiteWebApplication.php @@ -206,6 +206,7 @@ public function run() if ($this->page instanceof SiteExceptionPage) { $this->page->setException($e); + $this->page->setReportDialog($this->sentry_report_dialog); } $this->page->layout->init(); diff --git a/Site/pages/SiteExceptionPage.php b/Site/pages/SiteExceptionPage.php index 35145348..4062edea 100644 --- a/Site/pages/SiteExceptionPage.php +++ b/Site/pages/SiteExceptionPage.php @@ -28,6 +28,15 @@ public function setException($exception) } } + // }}} + // {{{ public function setReportDialog() + + public function setReportDialog($report_dialog) + { + // Not getting set???? + $this->report_dialog = $report_dialog; + } + // }}} // init phase @@ -116,6 +125,16 @@ protected function getSuggestions() return array(); } + // }}} + // {{{ protected function displaySentryReportDialog() + + protected function displaySentryReportDialog() + { + if ($report_dialog instanceof SiteSentryReportDialog) { + echo $this->sentry_report_dialog->getInlineXhtml(); + } + } + // }}} } diff --git a/Site/pages/SiteHttpErrorPage.php b/Site/pages/SiteHttpErrorPage.php index 0bcf29b5..4aae8e12 100644 --- a/Site/pages/SiteHttpErrorPage.php +++ b/Site/pages/SiteHttpErrorPage.php @@ -11,11 +11,6 @@ class SiteHttpErrorPage extends SitePage protected $http_status_code = null; protected $uri = null; - /** - * @var SiteSentryReportDialog - */ - protected $sentry_report_dialog; - // }}} // init phase @@ -46,8 +41,6 @@ public function init() } else { $this->uri = $_SERVER['REQUEST_URI']; } - - $this->sentry_report_dialog = new SiteSentryReportDialog(); } // }}} @@ -92,7 +85,6 @@ protected function display() $p_tag->display(); $this->displaySuggestions(); - $this->displaySentryReportDialog(); echo '

'; @@ -153,14 +145,6 @@ protected function getSuggestions() ); } - // }}} - // {{{ protected function displaySentryReportDialog() - - protected function displaySentryReportDialog() - { - echo $this->sentry_report_dialog->getInlineXhtml(); - } - // }}} // {{{ protected function sendHttpStatusHeader() diff --git a/Site/pages/SiteXhtmlExceptionPage.php b/Site/pages/SiteXhtmlExceptionPage.php index 7b971ec4..8c0580b2 100644 --- a/Site/pages/SiteXhtmlExceptionPage.php +++ b/Site/pages/SiteXhtmlExceptionPage.php @@ -46,6 +46,8 @@ protected function display() $this->displaySuggestions(); + $this->displaySentryReportDialog(); + if ($this->exception instanceof SwatException && !($this->exception instanceof SiteNotAuthorizedException)) { $this->exception->processAndContinue(); From 35ca197d94cb79522da6b700f5b5fae7d9968803 Mon Sep 17 00:00:00 2001 From: Kendra Kohler Date: Thu, 6 Dec 2018 19:39:06 -0400 Subject: [PATCH 7/7] js getting added to page --- Site/pages/SiteExceptionPage.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Site/pages/SiteExceptionPage.php b/Site/pages/SiteExceptionPage.php index 4062edea..c2ab6710 100644 --- a/Site/pages/SiteExceptionPage.php +++ b/Site/pages/SiteExceptionPage.php @@ -16,6 +16,11 @@ class SiteExceptionPage extends SitePage */ protected $exception; + /** + * @var SiteSentryReportDialog + */ + protected $report_dialog; + // }}} // {{{ public function setException() @@ -33,7 +38,6 @@ public function setException($exception) public function setReportDialog($report_dialog) { - // Not getting set???? $this->report_dialog = $report_dialog; } @@ -130,8 +134,8 @@ protected function getSuggestions() protected function displaySentryReportDialog() { - if ($report_dialog instanceof SiteSentryReportDialog) { - echo $this->sentry_report_dialog->getInlineXhtml(); + if ($this->report_dialog instanceof SiteSentryReportDialog) { + echo $this->report_dialog->getInlineXhtml(); } }