Zeka Posted February 27, 2019 Share Posted February 27, 2019 I have a module that listening for webhook notification on specific URL: <?php namespace ProcessWire; class ProcessPayments extends WireData implements Module, ConfigurableModule { public function init() { $this->addHookBefore('ProcessPageView::execute', $this, 'runPayments'); } public function ready() { } public function runPayments($event) { $it = isset($_GET['it']) ? $_GET['it'] : ""; if (substr($it, 0, 1) === '/') $it = ltrim($it, "/"); if (strpos($it, "webhooks/") !== false) { $this->checkRequest(); } else { return; } switch ($it) { case 'webhooks/pay': $this->handlePayRequest(); exit(); break; } } private function checkRequest() { $this->checkRequestHMAC(); return true; } ... } Currently, for debugging real request from a remote server I use logs, but this is so inconvenient and slow after using dumps from TracyDebugger ( @adrian is there something in TracyDebugger that can help? ). So looking for advice about how to debug such request, are there some tools for it? Link to comment Share on other sites More sharing options...
Rudy Posted February 27, 2019 Share Posted February 27, 2019 @Zeka we use http://bugsnag.com to debug remote/production sites. Their free plan is good enough for most people actually. 2 Link to comment Share on other sites More sharing options...
bernhard Posted February 27, 2019 Share Posted February 27, 2019 See tracy's Request Logger Panel 1 1 Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2019 Share Posted February 27, 2019 @Zeka - what @bernhard said ? His Request Logger panel is awesome for this! 1 Link to comment Share on other sites More sharing options...
Zeka Posted February 27, 2019 Author Share Posted February 27, 2019 @bernhard @adrian Wow, tracy's Request Logger Panel is what I was looking for and it works great with standard pages. But I have difficulties in getting it to work in my case. As you could see I hooking into 'before' ProcessPageView::execute in 'init' stage and I don't have any page or template for this URL, so there is no page object available and I can't use $this->wire('page')->logRequests(); That's all that I have from Tracy. Am I missing something? Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2019 Share Posted February 27, 2019 Is there a reason you can't move the hook to ready where you will have the page object? 1 Link to comment Share on other sites More sharing options...
Zeka Posted February 27, 2019 Author Share Posted February 27, 2019 Yes, I can't move it to ready as I need to change the output depending on an incoming request. Basically, I have to return {'code': 0} if I have a valid incoming request and on ready stage, I already have rendered 404 page. Maybe there is a better place for a hook? I have changed ProcessPageView::execute to ProcessPageView::ready and now everything works. Thank for the help, TracyDebugger and Logger panel! 4 Link to comment Share on other sites More sharing options...
bernhard Posted February 28, 2019 Share Posted February 28, 2019 @Zeka if you find time it would be great if you could write a little showcase/tutorial of this panel in the tracy thread ? Maybe Adrian could also use it for the docs...Everything is there already: https://adrianbj.github.io/TracyDebugger/#/debug-bar?id=request-logger ? Thx for the great work @Adrian! 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now