Plugin Directory

Changeset 3101173


Ignore:
Timestamp:
06/11/2024 12:25:43 PM (22 months ago)
Author:
edhicks
Message:

Omitting non 2xx requests from logging

Location:
simple-webstats
Files:
107 added
5 edited

Legend:

Unmodified
Added
Removed
  • simple-webstats/trunk/inc/collector.php

    r3062605 r3101173  
    2525                'ajaxURL' => sanitize_url(admin_url('admin-ajax.php')),
    2626                'viewNonce' => sanitize_text_field(wp_create_nonce('swstats_view_nonce')),
     27                'responseCode' => intval(http_response_code())
    2728            ));
    2829            wp_add_inline_script('swstats_collector', $inlineConfig, 'before');
  • simple-webstats/trunk/js/collector.js

    r3062605 r3101173  
    11(() => {
    22   
    3     let pageViewID = false;
    4    
    53    function recordView() {
    6         if(!swstatsConfig.viewNonce) return false;
     4        if(!swstatsConfig.viewNonce || !swstatsConfig.responseCode) return false;
    75        let data = {
    86            action: 'swstats_post_view',
     
    119            referrer: document.referrer
    1210        };
    13         sendData(data);
     11        if((swstatsConfig.responseCode >= 200) && (swstatsConfig.responseCode < 300)) sendData(data);
    1412    }
    1513   
  • simple-webstats/trunk/js/collector.min.js

    r3062605 r3101173  
    1 !function(){if(!swstatsConfig.viewNonce)return!1;!function(e,t){if(!swstatsConfig.ajaxURL)return!1;let o=[];Object.keys(e).forEach((t=>o.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]))));let n=o.join("&"),s=new XMLHttpRequest;s.open("POST",swstatsConfig.ajaxURL,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.onload=function(){if(this.status>=200&&this.status<400){let e=!1;this.response&&(e=JSON.parse(this.response)),e.error&&console.log("Simple Webstats Error: "+e.error),t&&e.data&&t(e.data)}},s.onerror=function(){console.log("Simple Webstats: Connection Error")},s.send(n)}({action:"swstats_post_view",nonce:swstatsConfig.viewNonce,location:window.location.pathname,referrer:document.referrer})}();
     1!function(){if(!swstatsConfig.viewNonce||!swstatsConfig.responseCode)return!1;let e={action:"swstats_post_view",nonce:swstatsConfig.viewNonce,location:window.location.pathname,referrer:document.referrer};swstatsConfig.responseCode>=200&&swstatsConfig.responseCode<300&&function(e,o){if(!swstatsConfig.ajaxURL)return!1;let t=[];Object.keys(e).forEach((o=>t.push(encodeURIComponent(o)+"="+encodeURIComponent(e[o]))));let s=t.join("&"),n=new XMLHttpRequest;n.open("POST",swstatsConfig.ajaxURL,!0),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.onload=function(){if(this.status>=200&&this.status<400){let e=!1;this.response&&(e=JSON.parse(this.response)),e.error&&console.log("Simple Webstats Error: "+e.error),o&&e.data&&o(e.data)}},n.onerror=function(){console.log("Simple Webstats: Connection Error")},n.send(s)}(e)}();
  • simple-webstats/trunk/readme.txt

    r3062608 r3101173  
    55Tested up to: 6.5
    66Requires PHP: 7.3
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99
     
    5050== Changelog ==
    5151
     52= 1.1.0 =
     53
     54* Omitted logging unsuccessful requests (e.g. 404s).
     55
    5256= 1.0.0 =
    5357
  • simple-webstats/trunk/simple-webstats.php

    r3062605 r3101173  
    44* Plugin Name: Simple Webstats
    55* Description: Privacy-focused cookie-free web analytics for WordPress.
    6 * Version: 1.0.0
     6* Version: 1.1.0
    77* Requires at least: 4.6
    88* Requires PHP: 7.3
     
    2020
    2121// config
    22 define('SWSTATS_VERSION', '1.0.0');
     22define('SWSTATS_VERSION', '1.1.0');
    2323define('SWSTATS_PATH',  plugin_dir_path(__FILE__));
    2424define('SWSTATS_URL',  plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.