adrian

Tracy Debugger

Recommended Posts

Maybe it has been asked before, but when I have TracyDebugger disabled I get this error in the console of my developer tools:

Quote

Uncaught TypeError: Cannot read property 'DebugPanel' of undefined at window.onload

Could this be avoided by a try-catch block? It is not too important, but it would be great to not have this error.

And I cannot mention enough how great your module is. It helped me a lot of times. ;)

  • Like 1

Share this post


Link to post
Share on other sites

Hi @AndZyk - this was actually just fixed yesterday. Please update and let me know if you still have any problems.

  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, adrian said:

So for me, there really is no noticeable difference in load times. But we have seen discrepancies like this before. I remember when kongondo had really slow load times with the three objects in this panel, but it didn't affect you at all. Could you maybe determine which one of these three is causing the main slowdown? If it's "Config Data", then I would suggest just disabling that and using the Console panel and doing: d($config) whenever you want that info.

I had the time to do some testing, here it comes (my MAMP Pro):

  • API variables: 0.3ms
  • Core Classes: 0.4ms
  • Config Data: 270ms
  • Version List: 14ms
  • API variables + Core Classes + Admin Link + Doc Links: 0.9ms

The result of d($config) is:
Frontend:
syntax error, unexpected end of file
File: .../site/assets/cache/TracyDebugger/consoleCode.php:2
1: <?php if(!defined("PROCESSWIRE")) die("no direct access"); $page = $pages->get(1);
2: d($config)

Admin:
Same as above + 500: Internal Server Error: See the browser dev console for the actual error

Why? It used to work.

BTW, links in this Info panel do not not use _blank, why? I keep forgetting it which is kinda annoying after while. Is it just me? :) 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, szabesz said:

The result of d($config) is:
Frontend:
syntax error, unexpected end of file

You're missing the line ending semicolon ;)

d($config);

So it looks like "Config Data" is the culprit on your setup. I don't really know why it's so slow for you, and I don't really know how to improve it. Anyone else seeing that? If others chime in with a similar experience, I'll see what I can do, but I think for the moment it's probably best to just disable that and use d($config); as needed.

 

6 hours ago, szabesz said:

BTW, links in this Info panel do not not use _blank, why? I keep forgetting it which is kinda annoying after while. Is it just me?

I used to be all about _blank links, but these days I actually find them annoying because they give you no choice. A normal link lets you choose - I have three-finger / midd-click setup for open in new tab. If you are finding it that annoying though, I'd be happy to add a config setting to make all those PW Info panel icon links optionally open in a new tab - just let me know.

  • Like 1

Share this post


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

You're missing the line ending semicolon

Double bother :-X I need to think, think, think harder next time :) This is the first time I see these errors, probably I got intimidated...

19 minutes ago, adrian said:

If you are finding it that annoying though, I'd be happy to add a config setting to make all those PW Info panel icon links optionally open in a new tab - just let me know.

Yes please!

19 minutes ago, adrian said:

and use d($config);

The problem with this that I get the result in a not too tall box with lots of scrolling an clicking and the presentation of it is not as "good" as the one with the panel.

What if there was a way to put custom settings onto the Panel Selector? Meaning module settings could be enabled/disabled for the Panel Selector, those one happens to switch on/of often. Currently I have no idea how the UI could be implemented for this, so this is just a blurry thought at this time.

Edited by szabesz
typo
  • Like 1

Share this post


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

Yes please!

Ok, I'll take care of that shortly - just keep in mind that I won't be adding "_blank" to the Login/Logout, Clear Session & Cookies, and Modules Refresh links, because these are actions that are designed to reload the same page once they complete, but I think all the others will be ok with an option for "_blank".

 

2 hours ago, szabesz said:

The problem with this that I get the result in a not too tall box with lots of scrolling an clicking and the presentation of it is not as "good" as the one with the panel.

What if there was a way to put custom settings onto the Panel Selector? Meaning module settings could be enabled/disabled for the Panel Selector, those one happens to switch on/of often. Currently I have no idea how the UI could be implemented for this, so this is just a blurry thought at this time.

Honestly I think this is starting to sound a little too complex. i have already added the Enable/Disable Strict Mode option, but I think I think it could get out of control if we're not careful. I'd really like to know why $config is so slow for you - how long does the Console panel response take when doing d($config); ? Just wondering if it's rendering $config itself that's the problem, or something about the way it is done in the PW Info panel that could be improved.

  • Like 1

Share this post


Link to post
Share on other sites

A quick update.

Thanks to lots of help from @szabesz we have fixed the issue with the Config Data section in PW Info panel from being slow.

The latest version also:

1) Fixes a ERR_BLOCKED_BY_XSS_AUDITOR browser error if there are <script> tags in your template file and you are using the Template Editor panel to test code changes.

2) Adds a new option for opening links from the PW Info panel in a new browser tab (off by default) - this was requested by @szabesz above.

3) Revamped the init() and ready() code so that much less code is processed when Tracy is completely or temporarily disabled. It also improves efficiency for various conditional checks.

4) Several other minor tweaks / fixes.

Please let me know if you come across any problems with this new version.

 

  • Like 4

Share this post


Link to post
Share on other sites

@adrian This morning I quickly crafted my own version of the "TracyEnableButton" in order to see if a smaller version can be made. The idea is that – in such small sizes the icons are used – using only lines should be enough to get very similar results. Of course, when an icon like this is enlarged its line only characteristics become prominent but I do not think it is an issue in our case. So here it comes:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54.48 57.24"><defs><style>.a{fill:none;stroke:#CD1818;stroke-miterlimit:10;stroke-width:8px;}</style></defs><title>turn-off</title><path class="a" d="M24,10.17a23.24,23.24,0,1,0,16,0" transform="translate(-4.76 -2)"/><line class="a" x1="27.24" x2="27.24" y2="21"/></svg>

Only 323 characters versus 1101 (current icon). What do you think? Is it usable, and if so worth the effort? I could produce all the others if you think it is a good idea.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, szabesz said:

@adrian This morning I quickly crafted my own version of the "TracyEnableButton" in order to see if a smaller version can be made. The idea is that – in such small sizes the icons are used – using only lines should be enough to get very similar results. Of course, when an icon like this is enlarged its line only characteristics become prominent but I do not think it is an issue in our case. So here it comes:


<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54.48 57.24"><defs><style>.a{fill:none;stroke:#CD1818;stroke-miterlimit:10;stroke-width:8px;}</style></defs><title>turn-off</title><path class="a" d="M24,10.17a23.24,23.24,0,1,0,16,0" transform="translate(-4.76 -2)"/><line class="a" x1="27.24" x2="27.24" y2="21"/></svg>

Only 323 characters versus 1101 (current icon). What do you think? Is it usable, and if so worth the effort? I could produce all the others if you think it is a good idea.

I like where you are headed with this and I think the new version looks nice. The only thing I wonder is whether it is worth re-crafting all the icons vs just running them through SVGO (which I should really have already done). I just used the online GUI for this test.

I just tried and it reduced it to 501 characters:

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 44.8 44.8">
  <g fill="#CD1818">
    <path d="M22.4 21.2c2 0 4-1.8 4-4V4c0-2-2-3.8-4-3.8s-4 1.7-4 3.8v13.5c0 2 2 4 4 4z"/>
    <path d="M30.7 3.3c-.5-.2-1 0-1.4.2-.5.3-.7.7-.7 1.3v5c0 .6.3 1.2.7 1.4 4.2 2.4 7 7 7 12 0 7.7-6.2 14-14 14-7.6 0-13.8-6.3-13.8-14 0-5 3-9.6 7-12 .4-.2.7-.8.7-1.3V4.4c0-.6-.2-1-.7-1.3C15 3 14.5 3 14 3 6.6 6.6 1 14 1 23c0 12.3 9.7 22 21.6 22 12 0 21.6-9.6 21.6-21.6 0-9-5.4-16.6-13.3-20z"/>
  </g>
</svg>

So there is definitely significant room for improvement with these icons. It's just a question of whether it's worth going the "line only" route, or just using SVGO to optimize the existing ones. Honestly I think most of the icons could do with some work - many of them are pretty ugly :) If you feel like taking this on, it would definitely be appreciated.

Anyone else have any thoughts?

  • Like 1

Share this post


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

It's just a question of whether it's worth going the "line only" route, or just using SVGO to optimize the existing ones.

Line-only versions are harder to do right because of its nature and limitations but I was thinking about going crazy with optimization regarding how much is injected into the page.

1 hour ago, adrian said:

worth re-crafting all the icons vs just running them through SVGO

By removing the probably not needed <title>turn-off</title> from my version (it was just exported too, as the name of the file was "turn-off") we have only 300 characters. Probably this is not the one where we can gain a lot but more complex ones like logos and such.

1 hour ago, adrian said:

If you feel like taking this on, it would definitely be appreciated.

I would be happy to do it. It is probably not worth forcing us to use line-only svg when more complex icons are needed but some of then (like this turn on/off icon called EnableButton) looks doable. Others might just need SVGO treatment :) 

I focused on EnableButton because I would like to see less in the source code of a frontend page when Tracy is disabled. So something like this (removing some line breaks) would be nice too:

<style>div#TracyEnableButton{bottom:10px!important;right:10px!important;z-index:99999!important;position:fixed!important;width:16px!important;height:16px!important;margin:0px!important;padding:0px!important;cursor:pointer!important;}div#TracyEnableButtonsvg{width:16px!important;height:16px!important;}</style>

I often use the Chrome extension called Quick source viewer which displays the actual rendered output in a different way then the inspector. For the styles I get the line breaks but if you could remove them we would get a more compact version injected.

Edited by szabesz
fix: So something like this (removing some line breaks) would be nice too:
  • Like 1

Share this post


Link to post
Share on other sites

All sounds great @szabesz The other possibility here is to use FontAwesome icons as much as possible. I recently added it for loading the icons for the new "Custom Links" section in the PW Info panel.  Although it is only loaded if you have defined some custom links. Because you guys can add a link to any page (admin Process or frontend) on the site, this was the only way to show the appropriate icon automatically. Not sure if this is a better or worse approach in terms of resources. Obviously Fontawesome isn't super lightweight, but it's also not embedding the SVG directly into the panels, so maybe more efficient?

14 minutes ago, szabesz said:

I focused on EnableButton because I would like to see less in the source code of a frontend page when Tracy is disabled. So I this removing some line break would be nice too:

Sounds like a good idea - I'll sort that out.

  • Like 1

Share this post


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

Obviously Fontawesome isn't super lightweight, but it's also not embedding the SVG directly into the panels, so maybe more efficient?

That reminds me of this tool I've somewhat forgotten about: http://fontello.com/
More efficient? Hard to tell... Maybe a custom set?

1 hour ago, adrian said:

Sounds like a good idea - I'll sort that out.

Thanks in advance! 

Share this post


Link to post
Share on other sites

I was about to suggest fontello but ten icons weighted about 10 kbyte, so 1 per char which seems heavier than svgs. Of course more or other chars can be perhaps less heavy.

Another option could be using unicode characters as icons but I'm not sure there are enough of them and browsers may display them differently. That would be super light though.

  • Like 1

Share this post


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

browsers may display them differently

Do you have any idea where it can be looked up? I mean, where we can check what is probably(?) supported by most modern OSes/browsers these days? It would be interesting to know. I guess the "cross-platform" typefaces are more or less the same as they have ever been but those font files seem to keep growing by added characters as the OSes evolve.

Share this post


Link to post
Share on other sites

I like the idea of unicode icons, but I am also not convinced that browser support is that consistent. I have seen screenshots of the Tracy console for example where the history back/forward icons don't look good. Also, I agree that there aren't enough options for our needs.

Something like a fontello custom set might be ok, but in general I have always thought that plain SVG icons were lighter, so I think I'd prefer to go with those I think. I wonder how much this really matters - is it over-optimization to be worrying about this?

Share this post


Link to post
Share on other sites

Hi @adrian,

I struck a problem trying to use bd() inside $sanitizer->pageNameUTF8().

If I add a bd() call to pageNameUTF8() like this...

public function pageNameUTF8($value) {
    bd($value, 'value');
    //...

...and then trigger the method like this...

$test = $sanitizer->pageNameUTF8('foo');

...then everything is fine so far and works as expected.

But as soon as I add the following to /site/config.php

$config->pageNameCharset = 'UTF8';

...then I get an error:

Quote

Fatal error: Uncaught Error: Call to undefined function ProcessWire\bd() in D:\Websites\__www\1testing\wire\core\Sanitizer.php:456

Any idea why this happens?

Share this post


Link to post
Share on other sites
37 minutes ago, Robin S said:

Any idea why this happens?

I think it's simply a matter of the order of things.

Without the pageNameCharset being set in config, the first call to the pageNameUTF8() sanitizer method is after init(), but when you set it, it must call that sanitizer method before Tracy has loaded. I did ask Ryan a long while back about the possibility of being able to load Tracy earlier - he said he might be amenable, but nothing ever came of it.

I just did some experiments loading the Tracy core files in the root index.php and with that setup, your bd() call still works, even with: $config->pageNameCharset = 'UTF8';

I'd like to revisit this idea with Ryan - I have come across bd() undefined many times when trying to use them in the PW core files - it would be great to have Tracy loaded before anything else.

I wonder if a request for this might be more powerful initiated by someone other than myself?

  • Like 1

Share this post


Link to post
Share on other sites

@adrian Hi,
I scanned the "docs" and could not find this tip of yours:
https://github.com/processwire/processwire-issues/issues/429#issuecomment-342976462
sounds like an important one.

Could you please consider adding it? Also, AJAX instructions are mostly in the Getting Started section which is fine but probably a dedicated "Debugging AJAX" or maybe "Working with AJAX" section with links to other related tips found on the page and additional tips like the one above would be nice to have.

Edited by szabesz
header name idea fix
  • Like 3

Share this post


Link to post
Share on other sites

Hey @szabesz - I really need to start the docs again from scratch. I have butchered that blog post so badly with new additions and most of the screenshots are really old. I'd really like to start a Github wiki for docs - @tpr has inspired me with the amazing job he has done on the docs for his modules using the wiki. The problem of course is time. I am already spending way too much time on module development and support and not enough time on paid client work - not meant to be an excuse, just a reality. And there are lots of others here putting in just as much time! 

I'd love to dedicate more time to PW module development, but of course that would mean paid modules - what to do ?

Maybe the Tracy docs could be a team effort - anyone interested? The problem is that there is no easy way to enable PRs on Gitbub wikis, although this might work: http://www.growingwiththeweb.com/2016/07/enabling-pull-requests-on-github-wikis.html

Any thoughts?

 

  • Like 3

Share this post


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

anyone interested?

+1 :)

13 minutes ago, adrian said:

The problem is that there is no easy way to enable PRs on Gitbub wikis, although this might work

I'm not fond of unsupported "hacky" solutions but it is just me :) Maybe a dedicated tool instead? I just googled a bit: https://www.penflip.com/

There could be alternatives, of course.

  • Like 1

Share this post


Link to post
Share on other sites

i don't know how the guys from uikit are doing it but they have nice docs and it seems that everybody can post suggestions (there is an edit button on all pages): https://getuikit.com/docs/icon

it's unbelievable how much you contributed to the community so far - a donation button would be the least imho. i've already asked you for that some time ago ;)

  • Like 3

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 BitPoet
      As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module.
      If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose.
      LoolEditor
      Edit office files directly in ProcessWire
      Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context.
      Currently supports opening and saving of office documents. Locking functionality is in development.
      See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly.
      Pull requests are welcome!
      Here is a short demonstration:

    • By Robin S
      An Images field allows you to:
      Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids.
      Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete.
       
      Files Rename Replace
      Allows files to be renamed or replaced in Page Edit.

      Usage
      Install the Files Rename Replace module.
      If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files.
      In Page Edit, click "Rename/Replace" for a file...
      Rename
      Use the text input to edit the existing name (excluding file extension).
      Replace
      Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same.
      Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved.
       
      https://github.com/Toutouwai/FilesRenameReplace
      http://modules.processwire.com/modules/files-rename-replace/
    • By d'Hinnisdaël
      So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile.
      This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image.
       

       
      Download & Info
      GitHub / Module directory / Readme / Usage
       
      Why ImageOptim?
      There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels.
       
      Installation
      Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory.
       
      Requirements
      To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case.
      I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back.
       
      ImageOptim account
      To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service.
       
      Usage (manual optimization)
      Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters.
      $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode
      Automatic optimization
      The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images.
      $image->size(800,600)->url // nothing to do here; image is optimized automatically
      To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization.
      $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false])
      For detailed usage instructions and all API parameters, see the usage instructions on GitHub.
       
      Filenames
      Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings.
       
      Roadmap
      Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary.
      Stability
      I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
    • By daniels
      General
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      It can update / create a subscriber in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe users to different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns You can find it here: https://github.com/danielstieber/SubscribeToMailchimp
      Let me know what you think and if I should add it to the Modules Directory.
      Setup
      Log into your Mailchimp account and go to  Profile > Extras > API Keys. If you don't have an API Key, create a new one. Copy your API Key and paste it in the module settings (Processwire > Modules > Site > SubscribeToMailchimp). Back in Mailchimp, go to the list, where you want your new subscribers. Go to Settings > List name and defaults. Copy the List ID an paste it in to the module settings.
      Usage
      To use the module, you need to load it into your template:
      $mc = $modules->get("SubscribeToMailchimp"); Now you can pass an email address to the module and it will try to edit (if the user exists) or create a new subscriber in your list.
      $mc->subscribe('john.doe@example.com'); You can also pass a data array, to add additional info.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe']); You can even choose an alternative list, if you don't want this subscriber in your default list.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe'], 'abcdef1356'); // Subscribe to List ID abcdef1356  
      Important Notes
      This module does not do any data validation. Use a sever-sided validation like Valitron Make sure that you have set up your fields in your Mailchimp list. You can do it at Settings > List fields and *|MERGE|* tags Example
      Example usage after a form is submitted on your page:
      // ... validation of form data $mc = $modules->get("SubscribeToMailchimp"); $email = $input->post->email; $subscriber = [ 'FNAME' => $input->post->firstname, 'LNAME' => $input->post->lastname, ]; $mc->subscribe($email, $subscriber);  
      Troubleshooting
      In case of trouble check your ProcessWire warning logs.
      I can't see the subscriber in the list
      If you have enabled double opt-in (it is enabled by default) you will not see the subscriber, until he confirmed the subscription in the email sent by Mailchimp
      I get an error in my ProccessWire warning logs
      Check if you have the right List ID and API Key. Check if you pass fields, that exist in your list. Check if you pass a valid email address. Go to Mailchimps Error Glossary for more Information
      How To Install
      Download the zip file at Github or clone directly the repo into your site/modules If you downloaded the zip file, extract it in your sites/modules directory. You might have to change the folders name to 'SubscribeToMailchimp'. Goto the modules admin page, click on refresh and install it  
    • By PWaddict
      Module for hiding pages for non-superusers.
      Download
      HidePages
      Requirements
      ProcessWire 3.x Changelog
      1.0.1 (31 March 2018)
      Module renamed to prevent confusion 1.0.0 (30 March 2018)
      Initial release