Plugin Directory

Changeset 3423385


Ignore:
Timestamp:
12/19/2025 06:19:07 AM (3 months ago)
Author:
usermaven
Message:

tagging version 1.2.4

Location:
usermaven
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • usermaven/tags/1.2.4/README.txt

    r3375626 r3423385  
    66Tested up to: 6.8.3
    77Requires PHP: 5.6
    8 Stable tag: 1.2.3
     8Stable tag: 1.2.4
    99License: Massachusetts Institute of Technology (MIT) license
    1010License URI: https://opensource.org/licenses/MIT
  • usermaven/tags/1.2.4/includes/class-usermaven-api.php

    r3240206 r3423385  
    44    private $api_key;
    55    private $api_url;
     6    private $cookie_less_tracking;
    67
    78    public function __construct($tracking_host) {
     
    910        $this->api_key = get_option('usermaven_api_key');
    1011        $this->api_url = "$tracking_host/api/v1/s2s/event";
     12        $this->cookie_less_tracking = (bool) get_option('usermaven_cookie_less_tracking');
    1113    }
    1214
     
    1719        $current_timestamp_ms = round(microtime(true) * 1000);
    1820        $doc_encoding = get_bloginfo('charset');
     21        $user_agent = $this->get_user_agent();
     22        $source_ip = $this->get_client_ip();
     23        $privacy_policies = $this->get_privacy_policies();
    1924
    2025        $data = [
     
    3237            'doc_path' => $_SERVER['REQUEST_URI'] ?? '',
    3338            'doc_host' => $_SERVER['HTTP_HOST'] ?? '',
    34             'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
     39            'user_agent' => $user_agent,
     40            'source_ip' => $source_ip,
    3541            'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '',
    3642            'doc_encoding' => (string) $doc_encoding,
    3743        ];
     44
     45        if (!empty($privacy_policies)) {
     46            $data = array_merge($data, $privacy_policies);
     47        }
    3848
    3949        $response = wp_remote_post($url, [
     
    4959        $body = wp_remote_retrieve_body($response);
    5060        $result = json_decode($body, true);
    51         return $result['status'] === 'ok';
     61       
     62        return isset($result['status']) && $result['status'] === 'ok';
    5263    }
    5364
     
    5768        // Get current timestamp in milliseconds
    5869        $current_timestamp_ms = round(microtime(true) * 1000);
     70        $user_agent = $this->get_user_agent();
     71        $source_ip = $this->get_client_ip();
     72        $privacy_policies = $this->get_privacy_policies();
    5973
    6074        $data = [
     
    7387            'doc_path' => $_SERVER['REQUEST_URI'] ?? '',
    7488            'doc_host' => $_SERVER['HTTP_HOST'] ?? '',
    75             'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
    76             'source_ip' => $_SERVER['REMOTE_ADDR'] ?? '',
     89            'user_agent' => $user_agent,
     90            'source_ip' => $source_ip,
    7791            'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '',
    7892            'doc_encoding' => 'UTF-8',
    7993        ];
     94
     95        if (!empty($privacy_policies)) {
     96            $data = array_merge($data, $privacy_policies);
     97        }
    8098
    8199        $response = wp_remote_post($url, [
     
    92110        $result = json_decode($body, true);
    93111
    94         return $result['status'] === 'ok';
     112        return isset($result['status']) && $result['status'] === 'ok';
     113    }
     114
     115    /**
     116     * Safely resolve client IP, preferring X-Forwarded-For when available.
     117     *
     118     * @return string
     119     */
     120    private function get_client_ip() {
     121        $ip_sources = array(
     122            'HTTP_X_FORWARDED_FOR',
     123            'REMOTE_ADDR',
     124        );
     125
     126        foreach ($ip_sources as $key) {
     127            if (empty($_SERVER[$key])) {
     128                continue;
     129            }
     130
     131            // X-Forwarded-For can contain multiple comma-separated addresses.
     132            $candidates = $key === 'HTTP_X_FORWARDED_FOR'
     133                ? explode(',', $_SERVER[$key])
     134                : array($_SERVER[$key]);
     135
     136            foreach ($candidates as $candidate) {
     137                $candidate = trim($candidate);
     138
     139                if (filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false ||
     140                    filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
     141                    return $candidate;
     142                }
     143            }
     144        }
     145
     146        return '';
     147    }
     148
     149    /**
     150     * Retrieve user agent string with a safe fallback.
     151     *
     152     * @return string
     153     */
     154    private function get_user_agent() {
     155        return isset($_SERVER['HTTP_USER_AGENT']) ? (string) $_SERVER['HTTP_USER_AGENT'] : '';
     156    }
     157
     158    /**
     159     * Return privacy flags when cookie-less tracking is enabled.
     160     *
     161     * @return array
     162     */
     163    private function get_privacy_policies() {
     164        if ($this->cookie_less_tracking) {
     165            return array(
     166                'cookie_policy' => 'strict',
     167                'ip_policy' => 'strict',
     168            );
     169        }
     170
     171        return array();
    95172    }
    96173}
  • usermaven/tags/1.2.4/includes/class-usermaven.php

    r3262123 r3423385  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.2.2';
     83            $this->version = '1.2.4';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/tags/1.2.4/usermaven.php

    r3375626 r3423385  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.2.3
     21 * Version:           1.2.4
    2222 * Author:            Usermaven
    2323 * Author URI:        https://usermaven.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'USERMAVEN_VERSION', '1.2.3' );
     40define( 'USERMAVEN_VERSION', '1.2.4' );
    4141
    4242/**
  • usermaven/trunk/README.txt

    r3375626 r3423385  
    66Tested up to: 6.8.3
    77Requires PHP: 5.6
    8 Stable tag: 1.2.3
     8Stable tag: 1.2.4
    99License: Massachusetts Institute of Technology (MIT) license
    1010License URI: https://opensource.org/licenses/MIT
  • usermaven/trunk/includes/class-usermaven-api.php

    r3240206 r3423385  
    44    private $api_key;
    55    private $api_url;
     6    private $cookie_less_tracking;
    67
    78    public function __construct($tracking_host) {
     
    910        $this->api_key = get_option('usermaven_api_key');
    1011        $this->api_url = "$tracking_host/api/v1/s2s/event";
     12        $this->cookie_less_tracking = (bool) get_option('usermaven_cookie_less_tracking');
    1113    }
    1214
     
    1719        $current_timestamp_ms = round(microtime(true) * 1000);
    1820        $doc_encoding = get_bloginfo('charset');
     21        $user_agent = $this->get_user_agent();
     22        $source_ip = $this->get_client_ip();
     23        $privacy_policies = $this->get_privacy_policies();
    1924
    2025        $data = [
     
    3237            'doc_path' => $_SERVER['REQUEST_URI'] ?? '',
    3338            'doc_host' => $_SERVER['HTTP_HOST'] ?? '',
    34             'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
     39            'user_agent' => $user_agent,
     40            'source_ip' => $source_ip,
    3541            'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '',
    3642            'doc_encoding' => (string) $doc_encoding,
    3743        ];
     44
     45        if (!empty($privacy_policies)) {
     46            $data = array_merge($data, $privacy_policies);
     47        }
    3848
    3949        $response = wp_remote_post($url, [
     
    4959        $body = wp_remote_retrieve_body($response);
    5060        $result = json_decode($body, true);
    51         return $result['status'] === 'ok';
     61       
     62        return isset($result['status']) && $result['status'] === 'ok';
    5263    }
    5364
     
    5768        // Get current timestamp in milliseconds
    5869        $current_timestamp_ms = round(microtime(true) * 1000);
     70        $user_agent = $this->get_user_agent();
     71        $source_ip = $this->get_client_ip();
     72        $privacy_policies = $this->get_privacy_policies();
    5973
    6074        $data = [
     
    7387            'doc_path' => $_SERVER['REQUEST_URI'] ?? '',
    7488            'doc_host' => $_SERVER['HTTP_HOST'] ?? '',
    75             'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
    76             'source_ip' => $_SERVER['REMOTE_ADDR'] ?? '',
     89            'user_agent' => $user_agent,
     90            'source_ip' => $source_ip,
    7791            'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '',
    7892            'doc_encoding' => 'UTF-8',
    7993        ];
     94
     95        if (!empty($privacy_policies)) {
     96            $data = array_merge($data, $privacy_policies);
     97        }
    8098
    8199        $response = wp_remote_post($url, [
     
    92110        $result = json_decode($body, true);
    93111
    94         return $result['status'] === 'ok';
     112        return isset($result['status']) && $result['status'] === 'ok';
     113    }
     114
     115    /**
     116     * Safely resolve client IP, preferring X-Forwarded-For when available.
     117     *
     118     * @return string
     119     */
     120    private function get_client_ip() {
     121        $ip_sources = array(
     122            'HTTP_X_FORWARDED_FOR',
     123            'REMOTE_ADDR',
     124        );
     125
     126        foreach ($ip_sources as $key) {
     127            if (empty($_SERVER[$key])) {
     128                continue;
     129            }
     130
     131            // X-Forwarded-For can contain multiple comma-separated addresses.
     132            $candidates = $key === 'HTTP_X_FORWARDED_FOR'
     133                ? explode(',', $_SERVER[$key])
     134                : array($_SERVER[$key]);
     135
     136            foreach ($candidates as $candidate) {
     137                $candidate = trim($candidate);
     138
     139                if (filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false ||
     140                    filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
     141                    return $candidate;
     142                }
     143            }
     144        }
     145
     146        return '';
     147    }
     148
     149    /**
     150     * Retrieve user agent string with a safe fallback.
     151     *
     152     * @return string
     153     */
     154    private function get_user_agent() {
     155        return isset($_SERVER['HTTP_USER_AGENT']) ? (string) $_SERVER['HTTP_USER_AGENT'] : '';
     156    }
     157
     158    /**
     159     * Return privacy flags when cookie-less tracking is enabled.
     160     *
     161     * @return array
     162     */
     163    private function get_privacy_policies() {
     164        if ($this->cookie_less_tracking) {
     165            return array(
     166                'cookie_policy' => 'strict',
     167                'ip_policy' => 'strict',
     168            );
     169        }
     170
     171        return array();
    95172    }
    96173}
  • usermaven/trunk/includes/class-usermaven.php

    r3262123 r3423385  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.2.2';
     83            $this->version = '1.2.4';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/trunk/usermaven.php

    r3375626 r3423385  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.2.3
     21 * Version:           1.2.4
    2222 * Author:            Usermaven
    2323 * Author URI:        https://usermaven.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'USERMAVEN_VERSION', '1.2.3' );
     40define( 'USERMAVEN_VERSION', '1.2.4' );
    4141
    4242/**
Note: See TracChangeset for help on using the changeset viewer.