Jump to content
adrian

Tracy Debugger

Recommended Posts

A couple of small updates to the Adminer panel / process module.

1) It is now restricted to the database for the PW install. Previously you could access all databases available with to the PW DB user. If some of you out there don't like this change, let me know and I can make it optional, but I think it's a better default (cleaner and a little safer).

2) It's now possible to uninstall the Adminer process module and it won't be automatically re-installed each time you upgrade Tracy - @Rudy was concerned about this with his setups. Obviously if a user has superuser access they can still install if they want, so it's more a case of removing something tempting for users without sufficient skills, rather than being a true change to security. On this note - Adminer is restricted to superusers (same with the Console, Snippet Runner and File Editor panels).

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

So imagine my shock today when i tried to d($var) and nothing happened (well, apart from a few crumbs of debug on the page)! Not again!, I groaned. I scanned Tracy's settings and nothing jumped at me. Everything seemed OK. I even tried debugInfo=>false/true, but no joy. A quick look at the docs and eureka! 

@options: DETECT | DEVELOPMENT | PRODUCTION

@default: DETECT

 

A docker container's IP address would be treated differently! It was being read as site is in 'PRODUCTION'!. A quick change to that setting and normal Tracy was back! You gave me a fright Tracy! I've never seen this side of you. We've only ever met 'locally' 😎.

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

@kongondo - glad you sorted it out 🙂 and good to know that docker appears to be a production server to Tracy.

Just out of curiosity - do you usually use d($var) in template files? I always use bd($var). The only place d($var) makes sense to me is in the Console panel. Maybe you have a different use case or preference, or something else, but thought I'd mention it just in case.

Share this post


Link to post
Share on other sites
5 minutes ago, adrian said:

Just out of curiosity - do you usually use d($var) in template files? I always use bd($var). The only place d($var) makes sense to me is in the Console panel. Maybe you have a different use case or preference, or something else, but thought I'd mention it just in case.

I normally use bd($var) and only knew about the difference with d($var) when you pointed it out to me recently :-).

  • Like 1

Share this post


Link to post
Share on other sites

A couple of new features worth mentioning:

1) The RequestInfo panel's Field List & Values section now has a new "Adminer" column with a link to open the row for chosen field for the current page directly in Adminer.

2) I have finally committed the autocompletions for PW methods, properties and $page fields for the Console and File Editor panels. Hopefully you'll find this a nice shortcut, but more importantly a learning experience by finding new methods you didn't know about (or forgot). 

 TSaG4LXarg.thumb.gif.5f0b169ddcf5392764634bfeebfd504a.gif

  • Like 4

Share this post


Link to post
Share on other sites

THIS. IS. AWESOME.

@adrian: A nice guy who never sleeps and always is improving. Master of Tracy and other girls 😉

Thank you. The autocomplete is, well I said it before: AWESOME!!!!

  • Like 2

Share this post


Link to post
Share on other sites

Hi all,

on the Module Information page of Process Tracy Adminer, when I click the link "check for updates" I get this  message:

Quote

Error reported by web service: Unable to find that module

What's going wrong?  Thank you for hints.

(PW 3.0.105, Tracy Debugger 4.14.11, PHP 7.0)

 

Share this post


Link to post
Share on other sites
2 hours ago, ottogal said:

Hi all,

on the Module Information page of Process Tracy Adminer, when I click the link "check for updates" I get this  message:

What's going wrong?  Thank you for hints.

(PW 3.0.105, Tracy Debugger 4.14.11, PHP 7.0)

 

That's because ProcessTracyAdminer is included as Part of TracyDebugger. This is a normal response for any included "helper" module in ProcessWire. Personally I don't like this behavior, but it is as expected. ProcessTracyAdminer will be automatically updated when you update TracyDebugger.

Share this post


Link to post
Share on other sites

Thank you for the clarification.

Shouldn't that response be replaced by a less irritating message?

Share this post


Link to post
Share on other sites
6 minutes ago, ottogal said:

Thank you for the clarification.

Shouldn't that response be replaced by a less irritating message?

Probably 🙂 - that would be a Github issue/request for Ryan if you're keen!

  • Haha 1

Share this post


Link to post
Share on other sites

I just added several new links to Adminer from the Request Info panel.

image.png.1b030d04bc5e0cb2d4f4e8a3e4f2c7fc.png

That Adminer icon links directly to this:

image.png.1be8aff15425baf033bdb8cedff8b265.png

 

These links have been added to the following Request Info sections:

Page Info
Module Settings
Template Settings
Template Info
Field Settings

Obviously be very careful editing content directly in the database like this - it's certainly possible to do critical damage!

Share this post


Link to post
Share on other sites
1 hour ago, adrian said:

Probably 🙂 - that would be a Github issue/request for Ryan if you're keen!

Done.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Adrian, just wanted to let you know that I just upgraded to latest TracyDebugger and received the following error on the API Explorer Panel:

Error: Call to a member function convertNamesToUrls() on null in /Users/glenn/websites/pwmlec/wwwroot/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/ApiExplorerPanel.php:205
Stack trace:
#0 /Users/glenn/websites/pwmlec/wwwroot/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/ApiExplorerPanel.php(108): ApiExplorerPanel->buildTable('adminTheme', Array)
#1 /Users/glenn/websites/pwmlec/wwwroot/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Bar.php(161): ApiExplorerPanel->getPanel()
#2 /Users/glenn/websites/pwmlec/wwwroot/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Bar.php(110): Tracy\Bar->renderPanels()
#3 /Users/glenn/websites/pwmlec/wwwroot/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Debugger.php(294): Tracy\Bar->render()
#4 [internal function]: Tracy\Debugger::shutdownHandler()
#5 {main}

Thanks for the all the improvements!  They look really helpful.

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, gmclelland said:

Hi Adrian, just wanted to let you know that I just upgraded to latest TracyDebugger and received the following error on the API Explorer Panel:

Thanks for letting me know - it happened when the load order of panels was different to what I had set up. It should be fixed in the latest version.

Share this post


Link to post
Share on other sites

New links from the Debug Mode panel's "Cache" section to edit it in Adminer:

image.png.355758f1bf657b8c06a0ed2fc2eb9c2d.png

Adminer DB icon links to where you can easily review the cache content, edit, change the expires datetime, or delete it.

image.png.5e7de2334a5c492ac097a4ffb0cf3b38.png

Also note that Adminer now has @bernhard's request for a PW icon link back to the site's PW admin backend.

Let me know if you guys have any suggestions for other direct links to Adminer - I am finding these very handy.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi @adrian I just created a PR with two new panels.

1) A hello world panel to make it easier for others to create panels and contribute to your great module:

GgSaxD7.png

2) A WebHook panel that should make it easier to debug and develop webhook based functionality (like GIT webhooks or webhooks from foxycart or any other 3rd party service):

Settings are simple:
1kKKJyc.png

The panel shows the latest requests to templates you selected (in this screenshot the basic-page template was also enabled):
0s7ALdf.png

You can also retrieve the data of logged requests, so it is easier to develop scripts without having to fire webhooks over and over again:

4Y2qJc1.png

Open to feedback, as always 🙂 https://github.com/adrianbj/TracyDebugger/pull/30

  • Like 3

Share this post


Link to post
Share on other sites

Hey @bernhard - this looks really fantastic - thank you!

I have a few comments re code styling to match the rest of Tracy, but I can clean that up after accepting the PR.

What I am wondering is if it might be useful to add a $page->getWebHookData() method so that you don't need to know the ID of the hook. Obviously the data that is stored would need to include a pageid (I see you already store that) so this new method could grab an array of objects just for this page. I think it would also be great to be able to do: $page->getWebHookData()->last() to get the last one. Not sure how useful first() and eq() would be in this case. Maybe eq() could be in reverse order so you could get eq(0) as the last received, eq(1) as second last, etc - what do you think?

I'll take a better look tomorrow and do some testing, but really excited to start using this!

  • Like 1

Share this post


Link to post
Share on other sites

Glad you like it 🙂 

10 hours ago, adrian said:

What I am wondering is if it might be useful to add a $page->getWebHookData() method so that you don't need to know the ID of the hook. Obviously the data that is stored would need to include a pageid (I see you already store that) so this new method could grab an array of objects just for this page.

Good idea!

I was also thinking of an AJAX version that grabs the latest requests every x seconds and updates the dumps. But that was too much effort for me for too little benefit. You might be faster as you know tracy a lot better than me.

10 hours ago, adrian said:

I have a few comments re code styling to match the rest of Tracy, but I can clean that up after accepting the PR.

Yeah, I prefer array syntax. You can adjust as needed.

 

Share this post


Link to post
Share on other sites
On 11/14/2018 at 7:03 PM, adrian said:

2) It's now possible to uninstall the Adminer process module and it won't be automatically re-installed each time you upgrade Tracy

Thanks for this, I think I will keep it uninstalled, partly because I do not like it's menu item to appear in the main menu. However, on he Tracy settings page:

Adminer settings are available here. results in a system message "Unknown module", so you might wan to change it to something like Adminer settings are only available when the Process Tracy Adminer module is installed.

Edited by szabesz
typos
  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, szabesz said:

Thanks for this, I think I will keep it uninstalled, partly because I do not like it's menu item to appear in the main menu. However, on he Tracy settings page:

Adminer settings are available here. results in a system message "Unknown module", so you might wan to change it to something like Adminer settings are only available when the Process Tracy Adminer module is installed.

Sorry about the issue with the unknown module error. I'll fix that in the next commit.

Keep in mind that if you don't want it to appear under the Setup menu, you just need to make Admin > Setup > Adminer hidden. That way you could still use the Adminer panel from the Tracy debug bar. Does that help? Also, I know it's obvious, but only superusers will see the Setup > Adminer option.

  • Like 1

Share this post


Link to post
Share on other sites
9 minutes ago, adrian said:

Keep in mind that if you don't want it to appear under the Setup menu, you just need to make Admin > Setup > Adminer hidden. That way you could still use the Adminer panel from the Tracy debug bar. Does that help?

Thanks for the tip! Yeah, I guess this will do the trick 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Well it took several hours of discussions with @bernhard and lots of back and forwards on the best way to do things, but we've finally committed the "WebHooks" panel he posted about above.

It's now called the Request Logger panel because in reality it is logging requests to a page on your site - who knows whether it's really a "webhook" request or something else.

Instructions

1) In the PW admin, edit the page you want to log incoming requests for.

2) Open the Request Logger panel.

3) Click the "Enable logging on this page" button.

image.png.f55ec8bcbcd7e2c305a8fb0129d874e3.png

4) Send a request to that page. This may be something like a confirmation of payment webhook call from Paypal etc. 

5) Reload the edit page in the PW admin to see the logged request. The reason we say to edit the page, rather than visit it on the frontend is because visiting the page would result in a logged request.

image.png.b52ea8d49ca25d2dac8f8a7cbbddfe96.png

Note that you can easily test incoming requests using the Postman app (https://www.getpostman.com/). You can choose POST or GET and under "Body" you'll want to specify Raw / JSON

image.png.9982322e32f5144bfae0b0466b2033ab.png

You'll notice the json supplied in the Postman Body is what shows up in the Request Logger panel under "input" and "inputParsed".

This is all well and good, but here's where the magic really comes in 🙂 There is a new getRequestData() method added to $page so you can get the logged data in your code. You can get logged requests by:

  • ID (shown in the title of the logged entry in the Request Logger panel)
  • ALL requests (an array of all logged requests for the page)
  • The last logged request by passing "true"
  • The current live request

This allows you to have access to the data sent by the webhook without constantly having to trigger it each time - ie no need to continually make test payments over and over as you refine and debug the your scripts that consume/parse this data! You can even make use of $page->getRequestData() in your final live code if you want - this does not rely on Tracy being enabled - it just has to be installed. So you could potentially execute one request and then use the "true" option while testing, and then when you're ready to go live, you can remove the "true" so it returns the live request.

There is a config setting to determine whether this method returns an array or an object.

image.png.8a45974c7747bb15a4cfc7d87c04de7e.png


Please take it for a test drive and let us know what you think!

@bernhard - did I miss anything worth mentioning?

  • Like 4

Share this post


Link to post
Share on other sites

Just wanted to upgrade her, but I got compile error: "Cannot declare class TracyDebugger, because the name is already in use", File: ...\modules\TracyDebugger\TracyDebugger.module.php:24  

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...