Jump to content

Tracy Debugger


adrian

Recommended Posts

Custom panels shipped with my own modules would be great ? 

Maybe Tracy could scan for /site/modules/***/TracyPanel***/ folders? So I could ship my module with two custom panels:

/site/modules/MyModule/TracyPanelFoo/Foo.php
/site/modules/MyModule/TracyPanelFoo/Foo.css
/site/modules/MyModule/TracyPanelFoo/Foo.js

/site/modules/MyModule/TracyPanelBar/Bar.php
/site/modules/MyModule/TracyPanelBar/Bar.css

// or like this?
/site/modules/MyModule/TracyPanels/Foo/Foo.php
/site/modules/MyModule/TracyPanels/Foo/Foo.css
/site/modules/MyModule/TracyPanels/Bar/Bar.php

thx again for this brilliant module!

  • Like 2
Link to comment
Share on other sites

13 hours ago, teppo said:

Sorry if this has been discussed already, there's so much stuff in this thread that I can't keep up anymore ?

A bit offtop... Maybe such epic modules like Tracy Debugger (and AOS, and some else, probably) could get their own sub-forums under Modules/Plugins? Kind of like Padloper got its own under Vip Support? I am sure, it can be done and (arguably) would make it easier for people to find stuff. But would it make it easier for maintainers? What do you think, @adrian?

  • Like 5
Link to comment
Share on other sites

4 hours ago, Ivan Gretsky said:

A bit offtop... Maybe such epic modules like Tracy Debugger (and AOS, and some else, probably) could get their own sub-forums under Modules/Plugins? Kind of like Padloper got its own under Vip Support? I am sure, it can be done and (arguably) would make it easier for people to find stuff. But would it make it easier for maintainers? What do you think, @adrian?

I think it's probably good idea, but this is a request for @Pete and @ryan

  • Like 1
Link to comment
Share on other sites

@teppo and @bernhard Please try the attached main module file. With this version, you can simply add your panel to your module directory structure eg:

/site/modules/TestModule/TracyPanels/TestThirdPartyModule.php

Make sure the class name of the panel in this example is: TestThirdPartyModulePanel

That should be all you need.

Not super well tested so let me know if you find any problems or have any suggestions. If everything looks good, I'll commit the changes to the repo.

 

TracyDebugger.module.php

  • Like 5
Link to comment
Share on other sites

Hi @adrian could you please provide instructions how to add new panels and what code to use for the panel? I tried it with something like my helloworldpanel - the panel showed up in the panel selector panel but when I enabled it I got

Error
Class 'TestThirdPartyModulePanel' not found search►

 

Link to comment
Share on other sites

@bernhard - not sure what to say. If you have a file called TestThirdPartModule.php and that file contains a class named "TestThirdPartyModulePanel" then it should work fine.

Note that you can name the file and class whatever you want, so long as the class is the same as the file with the "Panel" suffix.

Link to comment
Share on other sites

On 9/19/2020 at 3:21 AM, adrian said:

Not super well tested so let me know if you find any problems or have any suggestions. If everything looks good, I'll commit the changes to the repo.

Just gave this a quick try, and so far everything seems to work for me. Copied HelloWorldPanel to /site/modules/Wireframe/TracyPanels/Wireframe.php, renamed the class to WireframePanel, and changed labels. So far so good — it's not doing anything sensible yet, but seems to load just fine.

Will report back once I've had time to actually make the panel useful... ?

  • Like 3
Link to comment
Share on other sites

2 hours ago, teppo said:

Just gave this a quick try, and so far everything seems to work for me. Copied HelloWorldPanel to /site/modules/Wireframe/TracyPanels/Wireframe.php, renamed the class to WireframePanel, and changed labels. So far so good — it's not doing anything sensible yet, but seems to load just fine.

I would love to see a screenshot please as I am not sure I know what you folks are talking about ?. Thanks!.

Link to comment
Share on other sites

1 minute ago, kongondo said:

I would love to see a screenshot please as I am not sure I know what you folks are talking about ?. Thanks!.

It's just a way for other ProcessWire modules to add their own panels to Tracy's debug bar. The custom panel can display all sorts of relevant debug info, just like the core panels included with Tracy. Really it's up to module authors what they think would be useful info to display. 

I am also just working on the ability for these external module panels being able to inject settings into Tracy's main module settings so that users can customize the panel.

  • Like 2
Link to comment
Share on other sites

@teppo and @bernhard - new version attached. This lets you add module settings for your custom panels to Tracy's settings - you can add something like this to your panel class:

    public function addSettings() {
        $fieldset = $this->wire('modules')->get("InputfieldFieldset");
        $fieldset->attr('name+id', 'testThirdPartyModuleSettings');
        $fieldset->label = $this->_x('Test Third Party Module Settings', __FILE__);

        $f = $this->wire('modules')->get("InputfieldCheckbox");
        $f->attr('name', 'testThirdPartyModule_myCheckbox');
        $f->label = $this->_x('My Checkbox', __FILE__);
        $f->attr('checked', \TracyDebugger::getDataValue('testThirdPartyModule_myCheckbox') == '1' ? 'checked' : '');
        $fieldset->add($f);

        return $fieldset;
    }

The name of the field can be whatever you want, but I think you should prefix it with the class of the panel, eg: testThirdPartyModule_myCheckbox to avoid any conflicts with Tracy core panel settings. 

What do you guys think of this? Do you think there is a better way to implement? Would you rather store any needed settings in your module's settings instead?

Also, please note the name+id attribute in the fieldset - the value entered here should match the last parameter in the generatePanelFooter() method in your panel code. This links the cog icon at the bottom of your panel to the anchor link in Tracy's module settings.

TracyDebugger.module.php

  • Like 1
Link to comment
Share on other sites

@teppo and @bernhard - I am away this coming week so I have committed a new version of Tracy which includes the commits from above and a few additional fixes. Hopefully everything should be working properly now. Please test the new addSettings() method if you get a chance and if you need any additional changes to make things work, please feel free to modify Tracy as needed and send me a PR or let me know what else you need and I'll take care of it when I am back.

  • Like 2
Link to comment
Share on other sites

@adrian Hi Adrian, the latest version is throwing a warning if there are no external panels:

Quote

PHP Warning: Invalid argument supplied for foreach() in .../TracyDebugger/TracyDebugger.module.php:4079

I think this will only occur if there are no external panels, if the glob pattern is empty static::$externalPanels will be undefined (see TracyDebugger.module.php#L320-327). Should be fixed by initializing $externalPanels to an empty array (see L143). Thanks!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Hi @adrian,

In the Mail Interceptor panel, special characters are scrambled in the From field:

2020-10-08_133751.png.108f5d3810a69de432030f2f1c4490b2.png

I think this might be glitch in the Mail Interceptor panel rather than a WireMail issue because the From value seems to render properly in my email client. But if it isn't a Tracy issue and is actually a WireMail problem I'd want to report it to Ryan. Could you take a look when you have a chance? Thanks.

Link to comment
Share on other sites

Hi @Robin S - I can see the reason and have a fix, although I am not sure how robust it is.

The background is that in July 2016, @tpr was having some issues with some email clients needing the From name to be mime header encoded. He gave me this code to fix things:
https://github.com/adrianbj/TracyDebugger/blob/81dbda3fccbe961680f9b7a6bb76f055bf41a06f/panels/MailInterceptorPanel.php#L27-L29

                // from @tpr - for dealing with encoded fromName which is necessary for some email clients
                if(function_exists('mb_decode_mimeheader')) {
                    $item['fromName'] = mb_decode_mimeheader($item['fromName']);
                }

But it looks like the issue is when there are special characters that aren't encoded, this is breaking things. My attempted fix is replacing that with:

                if(function_exists('mb_decode_mimeheader') && mb_detect_encoding($item['fromName']) != 'UTF-8') {
                    $item['fromName'] = mb_decode_mimeheader($item['fromName']);
                }

but again, I am not sure how robust that is - encoding is not my speciality ?

Can you test that change for me.

Also, does anyone else have any thoughts on a better way to do this? @teppo - you must deal with these sorts of characters in email headers - any tips?

  • Like 1
Link to comment
Share on other sites

On 10/8/2020 at 8:32 AM, adrian said:

Also, does anyone else have any thoughts on a better way to do this? @teppo - you must deal with these sorts of characters in email headers - any tips?

Sorry, this is not my area of expertise either. Used to deal with that a lot, but thankfully no longer — switching all email sending features to use services like Mailgun has made my life so much better ?

Anyway, your solution seems reasonable. Only thing I'm wondering is whether it'd be better to specifically check for ASCII encoding with mb_detect_encoding(), instead of "not UTF-8"? It's a really small nuance, though.

  • Like 1
Link to comment
Share on other sites

On 10/10/2020 at 12:45 AM, teppo said:

Only thing I'm wondering is whether it'd be better to specifically check for ASCII encoding with mb_detect_encoding(), instead of "not UTF-8"?

Thanks for you input @teppo - I guess I went with this approach because I thought that there was a chance it could be encoded other non-UTF8 ways, not just ASCII, so I thought this was a safer approach, but again, I really don't like this stuff, so maybe I am still confused ? Can you explain why you think your way would actually be better?

Link to comment
Share on other sites

2 hours ago, adrian said:

Can you explain why you think your way would actually be better?

It seems to me that the only case when we'd want mb_decode_mimeheader() to run is when the header is encoded, in which case it's always base64 or quoted-printable (AFAIK), and these are always (US-)ASCII. I'm not aware of any notable issues with current approach, though; most likely the "worst case" is that you'd pass something that doesn't need decoding to mb_decode_mimeheader(), and it seems like a major coincidence if this operation actually ends up scrambling the data.

Anyway, the gist is that if we're looking for ASCII strings, it's better to be specific ?

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@adrian. Just an fyi,

I just upgraded tracy. Looking at the Adminer settings, it presents the check for update option. However, selecting that option returns the following error:

ProcessModule: Error reported by web service: That module is not currently tracked by the modules directory

Is it necessary to have the check for update option for adminer?

Link to comment
Share on other sites

4 minutes ago, rick said:

Looking at the Adminer settings, it presents the check for update option

That "Check for updates" option is a PW core thing - in my opinion this shouldn't show for child/helper modules that are shipped with a module, but that's a PW core issue and nothing I can change I'm afraid.

Link to comment
Share on other sites

37 minutes ago, adrian said:

a PW core thing - in my opinion this shouldn't show for child/helper modules that are shipped with a module,

@adrian. Is this currently possible though? Are you saying it is possible for ProcessWire to detect which modules are helper/child modules?

Link to comment
Share on other sites

  • adrian pinned and locked this topic
  • adrian unpinned and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...