Jump to content
adrian

Tracy Debugger

Recommended Posts

1 minute ago, PWaddict said:

@adrian Is it possible to view the values submitted on an ajax form and how?

Sure - just check out the RequestInfo panel on the AJAX bar and open up the Input POST section.

Does that get you what you want?

Share this post


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

Sure - just check out the RequestInfo panel on the AJAX bar and open up the Input POST section.

Does that get you what you want?

There are more than 1 bars??? How can I view the AJAX one?

Share this post


Link to post
Share on other sites
Just now, PWaddict said:

There are more than 1 bars??? How can I view the AJAX one?

The AJAX bar displays automatically when there has been an AJAX request - you can see this behavior when viewing the Page Tree in the PW admin, or triggering sub items from any of the admin menus, or any AJAX calls you make on the frontend.

You should also see "Redirect" bars when there has been a redirect call.

Do you not see any of these?

Share this post


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

The AJAX bar displays automatically when there has been an AJAX request - you can see this behavior when viewing the Page Tree in the PW admin, or triggering sub items from any of the admin menus, or any AJAX calls you make on the frontend.

You should also see "Redirect" bars when there has been a redirect call.

Do you not see any of these?

Ah yes only on backend I can see the AJAX one. On frontend I can't see it even though the entire site is based on AJAX.

Share this post


Link to post
Share on other sites
40 minutes ago, PWaddict said:

Ah yes only on backend I can see the AJAX one. On frontend I can't see it even though the entire site is based on AJAX.

Are you using a JS framework?

You need to make sure the X-Requested-With header is sent so that PHP (and therefore Tracy) can recognize it as an AJAX call. jQuery does this by default, but other frameworks may not, eg Angular.

In pure/vanilla JS, you can do:

xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");

In Angular you can do:

$http.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

 

  • Like 3

Share this post


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

Are you using a JS framework?

You need to make sure the X-Requested-With header is sent so that PHP (and therefore Tracy) can recognize it as an AJAX call. jQuery does this by default, but other frameworks may not, eg Angular.

In pure/vanilla JS, you can do:


xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");

 In Angular you can do:


$http.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

 

I'm using JQuery and on frontend I can see the header X-Requested-With: XMLHttpRequest but there is no AJAX bar.
On backend there is no X-Requested-With: XMLHttpRequest header but I can see the AJAX bar.

Share this post


Link to post
Share on other sites
18 minutes ago, PWaddict said:

I'm using JQuery and on frontend I can see the header X-Requested-With: XMLHttpRequest but there is no AJAX bar.
On backend there is no X-Requested-With: XMLHttpRequest header but I can see the AJAX bar.

Can you try this simple example in your template file:

<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

IZFZ2iCBzE.gif.29cefa65a889fb6284f07b61be5913f0.gif

  • Like 1

Share this post


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

Probably a silly question, but do you have Tracy enabled on the frontend? 

tracy-debug.jpg.5134601a5417fdc1d78cd9bfe13f8f9c.jpg

I haven't changed anything on module settings and yes it's enabled since I already can see the normal bar.

Share this post


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

Can you try this simple example in your template file:


<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

pubFcA6Bfn.thumb.gif.ba502b31274654b31b72b8ec71e1f610.gif

I still can't see the AJAX bar. Maybe the problem is caused by localhost?

Share this post


Link to post
Share on other sites

Hey @adrian, is there an API to turn Mail Interceptor on, before I send emails from one of my modules?

I would like to catch emails if I am on my local dev server and forgot to enable the Mail Interceptor in the Tracy Debug bar.

 

Share this post


Link to post
Share on other sites
11 minutes ago, PWaddict said:

I still can't see the AJAX bar. Maybe the problem is caused by localhost?

I am testing this on localhost.

Actually, I think the issue is probably the contents of the php file (in my example /data/testajax.php) that is being called via ajax. I forgot to provide that to you. It needs to bootstrap PW so that Tracy is also loaded, eg:

<?php

include '../index.php';

Hopefully if you do that, it should work as expected.

Share this post


Link to post
Share on other sites
2 minutes ago, jmartsch said:

Hey @adrian, is there an API to turn Mail Interceptor on, before I send emails from one of my modules?

I would like to catch emails if I am on my local dev server and forgot to enable the Mail Interceptor in the Tracy Debug bar.

It can be handled by the new stuff I set up recently. Have a read here: 

It allows you to set Tracy settings in config.php or config-dev.php (so it's local only).

I think this is probably the best solution. Let me know how you find it and if you have any suggestions for improvements.

PS - there is some further discussion about the instigation of this feature starting around here: https://processwire.com/talk/topic/5693-new-module-type-wiremail/?do=findComment&amp;comment=172371

  • Like 3

Share this post


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

Can you try this simple example in your template file:


<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

IZFZ2iCBzE.gif.29cefa65a889fb6284f07b61be5913f0.gif

This actually works. I forgot earlier to modify the url.

So it seems the problem is caused from the way I ajaxified the site. Anyway, thanks for the help.

Share this post


Link to post
Share on other sites
4 minutes ago, PWaddict said:

This actually works. I forgot earlier to modify the url.

So it seems the problem is caused from the way I ajaxified the site. Anyway, thanks for the help.

It should be pretty simple to figure out - if you're using jquery, then the only reason I think it wouldn't work is if you're not bootstrapping PW in the called php file. Anyway, good luck getting it sorted out.

Share this post


Link to post
Share on other sites

Hey @adrian

what do you think of adding a fullscreen button to the dump div right beside the collapse toggles? When having large dumps this could greatly improve readability and it would just need to apply a simple class with these css rules:

element.style {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 99999;
    width: 100%;
    height: 100%;
    background-color: #fff;
    overflow: scroll;
}

Then it could turn this:

rAyxgw5.png

Into that:

uqxsU3x.png

The collapse toggles still work. Of course we'd also need a "close fullscreen" button (or maybe ESC keyboard shortcut?)

  • Like 1

Share this post


Link to post
Share on other sites

Hey @bernhard - I like this, but I am thinking of maybe applying it to the entire results windows, rather than a specific dump result, so it would look like this. This way you would still have fullscreen, but it makes it easier to inspect the different dumps without needing to exit fullscreen and then initiate it on another dump.

Does this seem ok to you?

image.thumb.png.6c5e0c29f9c3848322a82775d0a3566f.png

  • Like 1

Share this post


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

Does this seem ok to you?

Sure! 🙂 Maybe - if it is easy - it would also make sense to have a fullscreen for the console code input. But that's only some ideas. Everything works great for me as it is. Just suggestions for improvements.

  • Like 2

Share this post


Link to post
Share on other sites

New version committed that adds a Maximize button to the Console panel as a whole which results in a fullscreen editing and review experience. Thanks to @tpr for his usual tweaks to my styling :)

I also added the regular fullscreen/halfscreen buttons to the Dumps and Dumps Recorder panels. These buttons are on several panels where the content can be quite large - they should have been on these panels all the time really.

Let me know if you have any issues with any of this - hopefully it should make things easier to work with.

  • Like 4

Share this post


Link to post
Share on other sites

wTnIdPt.png

Thx Adrian!

@adrian and @tpr any ideas what could be done about that AOS lang-switcher appearing on top of the panel? z-index doesn't seem to help strangely.

Share this post


Link to post
Share on other sites

Perhaps you can set a higher z-index in Tracy module's settings page, but I'll take a look when I have time.

Share this post


Link to post
Share on other sites

Thx, the strange thing is that I've already tried a z-index of 999999999999999999999999999999999 on the panel and the language switcher still appears on top?!

Share this post


Link to post
Share on other sites

z-index is tricky, if a parent element has lower index then you can't make a child element positioned above it. I hope I can modify AOS to overcome this.

  • Like 2

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 joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="optin" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="optin" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By MoritzLost
      This is a new module that provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Beta release
      Note that I consider this a Beta release. Since the module is relatively aggressive in deleting some caches, I would advise you to install in on a test environment before using it on a live site.
      Let me know if you're getting any errors, have trouble using the module or if you have suggestions for improvement!
      In particular, can someone let me know if this module causes any problems with the ProCache module? I don't own or use it, so I can't check. As far as I can tell, ProCache uses a folder inside the cache directory to cache static pages, so my module should be able to clear the ProCache site cache as well, I'd appreciate it if someone can test that for me.
      Future plans
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory

    • By David Karich
      Admin Page Tree Multiple Sorting
      ClassName: ProcessPageListMultipleSorting
      Extend the ordinary sort of children of a template in the admin page tree with multiple properties. For each template, you can define your own rule. Write each template (template-name) in a row, followed by a colon and then the additional field names for sorting.
      Example: All children of the template "blog" to be sorted in descending order according to the date of creation, then descending by modification date, and then by title. Type:
      blog: -created, -modified, title  Installation
      Copy the files for this module to /site/modules/ProcessPageListMultipleSorting/ In admin: Modules > Check for new modules. Install Module "Admin Page Tree Multible Sorting". Alternative in ProcessWire 2.4+
      Login to ProcessWire backend and go to Modules Click tab "New" and enter Module Class Name: "ProcessPageListMultipleSorting" Click "Download and Install"   Compatibility   I have currently tested the module only under PW 2.6+, but think that it works on older versions too. Maybe someone can give a feedback.     Download   PW-Repo: http://modules.processwire.com/modules/process-page-list-multiple-sorting/ GitHub: https://github.com/FlipZoomMedia/Processwire-ProcessPageListMultipleSorting     I hope someone can use the module. Have fun and best regards, David
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...