We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    aNoble is quite right; I would absolutely avoid calling the PageView "stats", and would say somthing like:

    Count page views? [x]
    This increments the PageView each time the document is hit. This may need to be switched off if you have a stats module installed.
      No, I don't know what OpenGeek's saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 25663 MODX Staff
      • 12,272 Posts
      I don’t see any reason why to switch it off, actually. It certainly shouldn’t interfere with an external stats app and it’s one less configuration choice to have to worry about. I’d like to see a lot less configuration options in the manager.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 25663 MODX Staff
        • 12,272 Posts
        If we modularize the existing stats, we’ll need to replace the logging parts that are currently embedded in the doc parser. This sounds like a perfect spot to insert an event hook as Jeff mentioned above. Any thoughts here?

        Doing so would let us have our cake and eat it too it seems on the surface.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 25663 MODX Staff
          • 12,272 Posts
          LOL ... and not 2 hours after this topic opens, i get this PM:

          We got this message from our server people, they’ve disabled modx as it’s over heating the servers cpu - any clues ?

          Server Logs
          | 47985 | skr_admin | localhost | skr_escorts | Query | 269 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 47995 | skr_admin | localhost | skr_escorts | Query | 269 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48132 | skr_admin | localhost | skr_escorts | Query | 72 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48167 | skr_admin | localhost | skr_escorts | Query | 87 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48168 | skr_admin | localhost | skr_escorts | Query | 87 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48195 | skr_admin | localhost | skr_escorts | Query | 72 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48227 | skr_admin | localhost | skr_escorts | Query | 72 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48250 | skr_admin | localhost | skr_escorts | Query | 87 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48331 | skr_admin | localhost | skr_escorts | Query | 71 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48332 | skr_admin | localhost | skr_escorts | Query | 29 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48345 | skr_admin | localhost | skr_escorts | Query | 72 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48396 | skr_admin | localhost | skr_escorts | Query | 17 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48447 | skr_admin | localhost | skr_escorts | Query | 17 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48455 | skr_admin | localhost | skr_escorts | Query | 72 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48562 | skr_admin | localhost | skr_escorts | Query | 17 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48570 | skr_admin | localhost | skr_escorts | Query | 60 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48665 | skr_admin | localhost | skr_escorts | Query | 4 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |
          | 48668 | skr_admin | localhost | skr_escorts | Query | 4 | Sending data | SELECT COUNT(DISTINCT(visitor)) FROM `skr_modx`.modx_log_access |

          Long story short, the built in stats are overloading the DB on the shared server they’re hosting on and they are likely going to get booted because of it:

          ah yes - it’s that what’s overloading the cpu ? Hostgator are ’really’ pissed they’ve put us in suspension pending the TAC abuse investigation.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 4018
            • 1,131 Posts
            Damn, Ryan! I’m glad I turned my logging off then and used Mint instead! Well then...I’d say we definitely need to address this then. I certainly wouldn’t want a bunch of devs screaming at us because something doesn’t work right.
              Jeff Whitfield

              "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
              • 25663 MODX Staff
              • 12,272 Posts
              And the conclusion:
              Yeah it’s a bummer all our pages were using that counter to keep track of individual page views, we disengaged it - the servers all happy now. The site got over 2 millon hits last month it’s gotten a little bigger than we thought it would, now it’s exceeding 100,000 hits a day must have been too much of a strain on the counter pushing our cpu usage off the chart.

              But the sites ’way’ quicker now too, so I’m pretty happy about that.

              Thanks again for your time Ryan
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 25663 MODX Staff
                • 12,272 Posts
                Jason and I were chatting about this topic, then Raymond and I chatted about it and it seems like everyone is pretty much on the same page. I think event hooks to better enable stats tracking could be included. Jason suggested onBeforePostProcess and onAfterPostProcess, with usage, e.g., of $this->invokeEvent(’onAfterPostProcess’); for most typical stats tracking applications.

                Only problem is, I’ve got no clue how to do this. Anyone want to take a stab?
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 25663 MODX Staff
                  • 12,272 Posts
                  On further inspection of the current trunk, it looks like the lines around line 942:
                  <?php
                        // check the logging cookie
                        if($this->config['track_visitors']==1 && !isset($_REQUEST['z'])) {
                  //        $this->checkCookie(); //TODO: replace this with proper call to a qualified logging tool
                        }
                  ?>


                  Could become:
                  <?php
                        // check the logging cookie
                        if($this->config['track_visitors']==1)) {
                            $this->invokeEvent('onBeforePostProcess'); 
                        }
                  ?>


                  and the code around line 508 from this:
                  <?php
                      if($this->config['track_visitors']==1 && !isset($_REQUEST['z'])) {
                        $this->log();
                      }
                  ?>


                  to:
                  <?php
                      if($this->config['track_visitors']==1) {
                        $this->invokeEvent('onAfterPostProcess');
                      }
                  


                  Also looks like the code around line 1577 can be removed:
                  <?php
                    function getSiteStats() {
                      $tbl = $this->getFullTableName("log_totals");
                      $sql = "SELECT * FROM $tbl";
                      $result = $this->dbQuery($sql);
                      $tmpRow = $this->fetchRow($result);
                      return $tmpRow;
                    }
                  ?>


                  Then we’d need to insert the appropriate events into the DB installer for new and upgrade installs and it should be ready for real stats tracking. Thoughts?
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 32963
                    • 1,732 Posts
                    Hi,

                    Joining the dicusssion on a late note but it’s better to be late than never.

                    In keeping with Jeff’s suggestions and a few others here’s what I would propose:

                    1) We convert the existing Stat system into a plugin/Module (Maybe called PageStats). This way user’s will be able will be able to (optional) read or us there existing system.

                    2) We create a new System Event called OnLogPageView. This way a developer can create his/her own Page view counter or statistic plugin/module.

                    3) Tune SlimStats and PageStats to use the OnLogPageView system event.

                    What do you all think?
                      xWisdom
                      www.xwisdomhtml.com
                      The fear of the Lord is the beginning of wisdom:
                      MODx Co-Founder - Create and do more with less.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Sounds good to me Raymond. Is the location above the appropriate location for the events, though?

                      I still am definitely in favor of a simple pagehit counter ... or a dedicated hits counter table.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me